Temp Folder

T

TARUN

I am facnig aproblem regarding the Temp Folder

I am using C#.Net
I use a Method
string temp = System.IO.Path.GetTempPath();

This will return the
C;\Document and Setting\John\Local Settings\Temp
but if i am running the same code in remote system then this will
return C:\Tmp

Why So, Please help me ... give the suggestionm for this

Regards,
Tarun Sinha
 
J

Jon Skeet [C# MVP]

I am facnig aproblem regarding the Temp Folder

I am using C#.Net
I use a Method
string temp = System.IO.Path.GetTempPath();

This will return the
C;\Document and Setting\John\Local Settings\Temp
but if i am running the same code in remote system then this will
return C:\Tmp

Why So, Please help me ... give the suggestionm for this

Perhaps the remote system has a temporary folder of c:\Tmp instead?
Why is this an issue?

Jon
 
T

TARUN

Perhaps the remote system has a temporary folder of c:\Tmp instead?
Why is this an issue?

Jon

Thank's for reply
So, is there any way to change the temp folder location....
Please tell me where we have to set the temp folder path ...
 
C

Chris Shepherd

TARUN said:
Thank's for reply
So, is there any way to change the temp folder location....
Please tell me where we have to set the temp folder path ...

Why do you need to *set* the temp folder path?

Chris.
 
T

TARUN

Why do you need to *set* the temp folder path?

Chris.

i need to write the pdf file in temp folder then take this path for
printing the pdf and delete it from here, for this purpose i use
System.IO.Path.GetTempPath(); method which return C:\Document and
Setinng\John\Local Settings\Temp\
but if i run same code in my remote machince this method return C:
\Tmp .. So i need to change the Tmp folder to C:\Document and Setinng
\John\Local Settings\Temp\ for remote machice.

Please suggest me if it poosible to change the Temp folder of the
user ...

Thank's
Tarun Sinha
 
J

Jon Skeet [C# MVP]

i need to write the pdf file in temp folder then take this path for
printing the pdf and delete it from here, for this purpose i use
System.IO.Path.GetTempPath(); method which return C:\Document and
Setinng\John\Local Settings\Temp\
but if i run same code in my remote machince this method return C:
\Tmp .. So i need to change the Tmp folder to C:\Document and Setinng
\John\Local Settings\Temp\ for remote machice.

Please suggest me if it poosible to change the Temp folder of the
user ...

This sounds like a really bad way of going about things. You really
shouldn't be changing the temp folder of users. Could you explain more
about the issue, including why there are two machines involved, and
why they'd need to use the same folder?

Jon
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

TARUN said:
Thank's for reply
So, is there any way to change the temp folder location....
Please tell me where we have to set the temp folder path ...

why you need to change it?
The WHOLE idea of a method like System.IO.Path.GetTempPath(); is that you DO
NOT NEED TO KNOW beforehand where the folder really is.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

i need to write the pdf file in temp folder then take this path for
printing the pdf and delete it from here, for this purpose i use
System.IO.Path.GetTempPath(); method which return C:\Document and
Setinng\John\Local Settings\Temp\

Again, the idea is that you be able to work in any environment without
having to hardcode values.

According to what you describe I would use GetTempFileName instead. With
this method you get a filename that is unique. you can do whatever you want
with it. If you keep the name of this file around your program can
open/read/close it as many times and from as many places as you want.
 
C

Chris Shepherd

Ignacio said:
Again, the idea is that you be able to work in any environment without
having to hardcode values.

According to what you describe I would use GetTempFileName instead. With
this method you get a filename that is unique. you can do whatever you want
with it. If you keep the name of this file around your program can
open/read/close it as many times and from as many places as you want.

This is the approach I've always used when dealing with temporary files.

Chris.
 
M

Michael Burgess

I am facnig aproblem regarding the Temp Folder

I am using C#.Net
I use a Method
string temp = System.IO.Path.GetTempPath();

This will return the
C;\Document and Setting\John\Local Settings\Temp
but if i am running the same code in remote system then this will
return C:\Tmp

Why So, Please help me ... give the suggestionm for this

Regards,
Tarun Sinha

Can't you just have a path in a configuration file that contains your
chosen temp path?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top