Reputation: 1713
I want to create a program that saves a bmp picture to my documents and uses that picture as wallpaper. So far I managed to create the program and it runes pretty nice. But one problem, I dont know how to save the bmp file to my documents (every computer has a different path). Please help me find out a way to find the path to my documents.
System.Drawing.Image img = Properties.Resources.pic;
img.Save("D:\\wall.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true);
key.SetValue(@"Wallpaper", "D:\\wall.bmp");
RegistryKey key2 = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true);
key2.SetValue(@"WallpaperStyle", 2.ToString());
key2.SetValue(@"TileWallpaper", 0.ToString());
SystemParametersInfo(
SPI_SETDESKWALLPAPER,
0,
"D:\\wall.bmp",
SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
Upvotes: 1
Views: 6111
Reputation: 25056
I suspect you want the Environment.SpecialFolder
enumeration:
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx
and combine it with Environment.GetFolderPath
:
http://msdn.microsoft.com/en-us/library/system.environment.getfolderpath.aspx
Upvotes: 1