Saving a File to the Desktop

  • Thread starter Thread starter Devlei
  • Start date Start date
D

Devlei

I want to be able to save a file to the Desktop. I realise the Desktop
path varies according to the version of Windows being used. Can
some-one help me with the following three issues:
1. Is the best option to use 'Environment.OSVersion.Version.Major' to
determine which version of Windows?
2. What values do each of the Windows versions have for point 1 above?
3. I know the path for XP (C:\Documents and Settings\" & strUserName &
"\Desktop\) and for Windows 98 (C:\Windows\Desktop\), but can anyone
help me what the paths for the other Windows versions would be?

With thanks
 
Devlei said:
I want to be able to save a file to the Desktop. I realise the Desktop
path varies according to the version of Windows being used.
[...]
3. I know the path for XP (C:\Documents and Settings\" & strUserName &
"\Desktop\) and for Windows 98 (C:\Windows\Desktop\), but can anyone
help me what the paths for the other Windows versions would be?

'Environment.GetFolderPath(Environment.SpecialFolder.Desktop)' should return
the correct path on all versions of Windows supported by the .NET Framework.
 
Devlei said:
I want to be able to save a file to the Desktop.

Just use

Dim deskDir As String =
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)

That should give you desktop folder.
 
Back
Top