473,466 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Directory.CreateDirectory

Tom
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.

Jul 9 '08 #1
4 2546
Tom
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" <jo***********@hotmail.comwrote in message
news:BD**********************************@microsof t.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.
Jul 9 '08 #2
What type of application are you doing? When you say move code to "server",
does that mean a ASP.NET application, a Windows service application or a
desktop application? Without knowing which user account is used to run your
app, it is hard to tell what is wrong. But it ceratinly sounds like you have
permission problem. As for the code not throwing exception, if the code you
show is the real code, then of course the code does throw exception and is
caught in catch(){} block. However, since you did nothng in the "catch..."
block, the code continues. That is, if you use try...catch... and do nothing
when exception ia caught, that is equal to ignorig the exception and the
code would continue counting on your luck to finish.

"Tom" <jo***********@hotmail.comwrote in message
news:BD**********************************@microsof t.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.
Jul 9 '08 #3
Tom
I found the problem. It was a sync issue. This was a plug-in for a Windows
service. Another plug-in was deleting temp directories.

Sorry to bug everyone.
"Norman Yuan" <Fa******@FakeEmail.Notwrote in message
news:eR**************@TK2MSFTNGP03.phx.gbl...
What type of application are you doing? When you say move code to
"server", does that mean a ASP.NET application, a Windows service
application or a desktop application? Without knowing which user account
is used to run your app, it is hard to tell what is wrong. But it
ceratinly sounds like you have permission problem. As for the code not
throwing exception, if the code you show is the real code, then of course
the code does throw exception and is caught in catch(){} block. However,
since you did nothng in the "catch..." block, the code continues. That is,
if you use try...catch... and do nothing when exception ia caught, that is
equal to ignorig the exception and the code would continue counting on
your luck to finish.

"Tom" <jo***********@hotmail.comwrote in message
news:BD**********************************@microsof t.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.
Jul 9 '08 #4
tim
Try using System.IO.Path.Combine() method instead of string concat.

"Tom" <jo***********@hotmail.comwrote in message
news:61**********************************@microsof t.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" <jo***********@hotmail.comwrote in message
news:BD**********************************@microsof t.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.
Jul 26 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: MAF | last post by:
How do I create a directory inside C#?
1
by: Daniel | last post by:
If I call CreateDirectory(\\\\devDriveA\\foo\\bar\\a\\b\\c) and \\devDriveA\foo\bar already exists then sub directories a\b\c don't get created. When I use CreateDirectory on my own file system,...
1
by: H.B. | last post by:
Hi, Is there a way to avoid conflicts between CreateDirectory() (from API) and Directory::CreateDirectory(). The other functions from Directory class works(Exists() as example). It seems to be...
3
by: James Coleman | last post by:
Hello, The following error is appearing when attempting to create a directory using the availale system.io methods: System.IO.DirectoryNotFoundException: Could not find a part of the path...
2
by: Paul Bromley | last post by:
How can I create a directory within a shared ntwork directory?? sServerName - is the Server name "\Docs" - is the shared directory "\Others" - is the directory to create. The following...
23
by: **Developer** | last post by:
Is there an easy way to copies all files in a directory into another directory? What about coping subdirectories too? Thanks in advance for any info
2
by: CCLeasing | last post by:
If (Directory.Exists(@"c:\indigo\" + txtOfficial + @"\" + comOffice.Text + @"\" + numTerm.Value.ToString())) { storereport(); } else { Directory.CreateDirectory(@"c:\indigo\" + txtOfficial +...
2
by: Toolsmith | last post by:
The following code: C# code: Directory.CreateDirectory("D:\\somewhere\\somewhereelse\\here\\") works, but the following does flags the error: An unhandled exception of type...
4
by: Robert | last post by:
Greetings New to Visual Studio 2008. Always us VB6.0 SP5. I am trying to copy files from A to B. I select a directory, and copy files. Works ok, but it does not create the directory first. ...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.