2013-07-17 2 views
2

이 질문은 상당히 현지화되어있을 수 있지만 여기에서 내가 잘못하고있는 것에 대한 다른 의견이 필요합니다. 프로세스의 모든 단계에서 모든 것이 정상적이고 정상인 것처럼 보이는 경우 어떻게하면 임시 파일의 경로에 불법 문자를 전달할 수 있습니까?경로 신비의 잘못된 문자

내가이납니다 :

파일이 지정된 위치에 존재
XmlDocument doc = new XmlDocument(); 
doc.Load(<above string>); 

(I '이에

"C:\Documents and Settings\<username>\Local Settings\Temp\1\tmp1E0.tmp"

:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Illegal characters in path. 

이 통과 할 때 비록 실행 중에 그것을 확인했다.) System.IO.File.Exists는 thinks otherwis 이자형; 나는 명백한 것을 볼 수 없다. 나는 그걸 해결하려고 노력할만한 것이 있습니까?

요청시

더 많은 코드를 사용할 수 :

REQ1 :어떻게 경로가 선언되고있다?

try 
{ 
    session.TempConfigDir = System.IO.Path.GetTempFileName(); 
    //All work done with the temp file happens within the Form 
    Form currentform = new WelcomeDialog(session); 
    DialogResult dr = currentform.ShowDialog(); 
} 
finally 
{ 
    File.Delete(session.TempConfigDir); 
} 

세션 변수은 다양한 위치에 주위에 전달되지만 변경되지 않습니다.

REQ2 :실제로 <username>을 사용하고 있습니까?

아니요, 편집했습니다. 유효한 Windows 사용자 이름입니다.

REQ3 :디버깅에서 어떻게 되나요?

실제로 이것은 설치 프로그램 (실제로는 물리적으로 디버그하기가 어렵습니다)에서 발생하지만 위의 문자열은 유효한 사용자 이름으로 로그에서 얻을 수있는 예제입니다.

REQ4 :사용 방법에 대한 자세한 코드는 무엇입니까?

여기에 WiX3.7이 포함되어 있기 때문에 WiX 태그를 추가하고 있습니다. WiX3.7의 MSI 내

//It's grabbing the web.config from an existing install 
//and copying it over the temp file, not changing its location or name. 
File.Copy(m_Session.INSTALLDIR + DIR_WEB_CONFIG, m_Session.TempConfigDir, true); 

에서 :

기본 데이터 잡고 클래스 : 양식 내에서

public class SessionState 
{ 
    //<other properties> 
    public string TempConfigDir { get; set; } 

    public SessionState() 
    { 
     //Setting of properties 
    } 
} 

:

//StringBuilder for arguments 
installerargs.Append("\" TEMPCONFIGDIR=\""); 
installerargs.Append(m_Session.TempConfigDir); 
//... 
Process p = Process.Start("msiexec", installerargs.ToString()); 
p.WaitForExit(); 

APPEND : 파트 양식에서 놓친 :

<Property Id="TEMPCONFIGDIR" Value="UNSET" /> 

...

<Custom Action="CA_InstallUICA.SetProp" After="StartServices">NOT Installed</Custom> 
<Custom Action="CA_InstallUICA" After="CA_InstallUICA.SetProp">NOT Installed</Custom> 

합니다 ... 사용자 지정 작업 내에서
<CustomAction Id="CA_InstallUICA.SetProp" Property="CA_InstallUICA" Value="rcswebdir=[MCWSVDIR];webdir=[WEBAPPVDIR];installtype=notransaction;targetdir=[INSTALLDIR];interaction=[INTERACTION];tempconfigdir=&quot;[TEMPCONFIGDIR]&quot;;" /> 

이 그것을 사용

wz.AutoSettings.TempConfigLocation = session.CustomActionData["tempconfigdir"]; 
//Where I get the above string passed out 
session.Log(wz.AutoSettings.TempConfigLocation); 
//The rest of the code that uses it is above and where the exception is thrown 

REQ5 :당신이 something.xml하는 TempConfigDir 변수를 변경합니까?

아니요, xml 파일을 제공된 정확한 이름/디렉토리 (예 : .tmp)에 복사합니다.

REQ6 :정말로드 중입니까()?

예, 저는 각 줄을 기록하고 실행시 첫 번째 줄만 기록했습니다.

+1

@ "C : \ Documents and Settings \ SRanson \ Local Setti ngs \ Temp \ 1 \ tmp1E0.tmp " –

+3

문자열에" "이 실제로 포함되지 않는다고 가정합니다."> "및"< "는 경로에서 유효하지 않은 문자이므로) –

+1

@VictorMukherjee : 이것에 대해 생각했지만 사실, 문자열은 알 수없는 이스케이프 문자열 (\ D, \ S, \ L, \ T, \ 1)을 가지고 있기 때문에 컴파일되지 않습니다. –

답변

2

이 줄은 의심 보인다

경로를 인용 부분은 따라서 예외 생산, 따옴표를 두 배로 될 가능성이 나타납니다

<CustomAction Id="CA_InstallUICA.SetProp" Property="CA_InstallUICA" Value="rcswebdir=[MCWSVDIR];webdir=[WEBAPPVDIR];installtype=notransaction;targetdir=[INSTALLDIR];interaction=[INTERACTION];tempconfigdir=&quot;[TEMPCONFIGDIR]&quot;;" /> 
:

tempconfigdir=&quot;[TEMPCONFIGDIR]&quot; 

실제 경로를 제공하기 위해 &quote; 포장을 제거를 :

tempconfigdir=[TEMPCONFIGDIR]