Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Anyone know how to get Path.GetTempPath to return long file names 1

Status
Not open for further replies.

SBendBuckeye

Programmer
May 22, 2002
2,166
US
It returns c:\Tempor~1\, etc. Thanks in advance!

Have a great day!

j2consulting@yahoo.com
 
Interesting problem - a possible solution:

Have a look in the Registry at:

HKEY_CURRENT_USER\Environment

on my machine there are two temp entries:

TEMP
%USERPROFILE%\Local Settings\Temp

TMP
%USERPROFILE%\Local Settings\Temp

additionally %USERPROFILE% is an Environment variable and this shows the full path as in:

C:\Documents and Settings\My Name

A bit of concatenation should be able to do the rest.


Hope this helps.


[vampire][bat]
 
Forget what I said above - this does it all:

Code:
    Dim rk As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser
    Dim tmp As String = rk.OpenSubKey("Environment").GetValue("Temp").ToString
    rk.Close()
    MessageBox.Show(tmp)


Hope this helps.

[vampire][bat]
 
Thanks E&F. I can't figure out why they would do something like that with the Path class.

Have a great day!

j2consulting@yahoo.com
 
I think its simpler than that.

If you type SET at a DOS prompt you will find something like:

TEMP=C:\DOCUME~1\MYNAME~1\LOCALS~1\Temp
TMP=C:\DOCUME~1\MYNAME~1\LOCALS~1\Temp

and I would guess that that is what Path.GetTempPath picks up. Before coming up with my solution, I also had a look at the Scripting library's FileSystemObject and that produced the same DOS style output.

[vampire][bat]
 
I think FileScriptingObject at least has some options for long vs short file names, but oh well. Thanks again.

Have a great day!

j2consulting@yahoo.com
 
You are looking at global variables. You can get to them with the SET command from a DOS prompt, or (in XP) by right clicking on My Computer -> Properties -> Advanced -> Environmental Variables. In 2k I >think< it is right click on My Computer -> Properties -> Environment

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
This has been an interesting thread to say the least. Path dot gives you about every possible path property you can think of, interesting that at least some of them are coming from old DOS stuff.

Have a great day!

j2consulting@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top