![]() |
|
|
|||
|
Re: Directory.CreateDirectory
Even more weird, if I change the code to this:
private static readonly string mString = "tempUnzipDir" + Path.DirectorySeparatorChar + "anotherDir" + Path.DirectorySeparatorChar; .... public static string ExtractToTempLocation(string aZip) { try { string tmp = Path.GetTempPath() + mString; Directory.CreateDirectory(tmp); // Extract the zip file } catch(Exception e) { } } I see the directory "tempUnzipDir" get created under the administrator's temporary directory. However, the directory [administrator's temp path]\tempUnzipDir\anotherDir does not get created. WTH??!!! "Tom" <johnthompson1@hotmail.com> wrote in message news:BDD91C65-40DD-433F-8932-18E1A089EE12@microsoft.com... > This is really weird, but I have the following code: > > private static readonly string mString = "tempUnzipDir" + > Path.DirectorySeparatorChar; > > ... > > public static string ExtractToTempLocation(string aZip) > { > try > { > string tmp = Path.GetTempPath() + mString; > Directory.CreateDirectory(tmp); > // Extract the zip file > } > catch(Exception e) > { > } > } > > The code above creates a temporary directory fine on my dev machine > (Vista), but will not create a temp directory on my server (server 2K3 R2) > when I move the code over the to server. I have some logging enabled that > isn't shown in the code above, and it is definately pointing to the > correct location of the temp directory to be created. Even more weird is > that the call to Directory.CreateDirectory(tmp); does not throw any type > of exception on the server. It just keeps executing as if it worked > correctly. Does anybody have any ideas why this isn't working? > > Thanks. > |
|
|||
|
Re: Directory.CreateDirectory
Try using System.IO.Path.Combine() method instead of string concat.
"Tom" <johnthompson1@hotmail.com> wrote in message news:61B35E73-2802-481A-BF57-5F1E87717663@microsoft.com... > Even more weird, if I change the code to this: > private static readonly string mString = "tempUnzipDir" + > Path.DirectorySeparatorChar + "anotherDir" + Path.DirectorySeparatorChar; > > ... > > public static string ExtractToTempLocation(string aZip) > { > try > { > string tmp = Path.GetTempPath() + mString; > Directory.CreateDirectory(tmp); > // Extract the zip file > } > catch(Exception e) > { > } > } > > I see the directory "tempUnzipDir" get created under the administrator's > temporary directory. However, the directory [administrator's temp > path]\tempUnzipDir\anotherDir does not get created. WTH??!!! > > > > "Tom" <johnthompson1@hotmail.com> wrote in message > news:BDD91C65-40DD-433F-8932-18E1A089EE12@microsoft.com... >> This is really weird, but I have the following code: >> >> private static readonly string mString = "tempUnzipDir" + >> Path.DirectorySeparatorChar; >> >> ... >> >> public static string ExtractToTempLocation(string aZip) >> { >> try >> { >> string tmp = Path.GetTempPath() + mString; >> Directory.CreateDirectory(tmp); >> // Extract the zip file >> } >> catch(Exception e) >> { >> } >> } >> >> The code above creates a temporary directory fine on my dev machine >> (Vista), but will not create a temp directory on my server (server 2K3 >> R2) when I move the code over the to server. I have some logging enabled >> that isn't shown in the code above, and it is definately pointing to the >> correct location of the temp directory to be created. Even more weird is >> that the call to Directory.CreateDirectory(tmp); does not throw any type >> of exception on the server. It just keeps executing as if it worked >> correctly. Does anybody have any ideas why this isn't working? >> >> Thanks. >> > |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|