0

我正在使用 url 下载图像并保存当前用户登录路径,但发生的错误是 gdi+ 中发生的一般错误。因为我认为系统获取这种格式的路径:-C:\\Users\\admin\\Pictures 但我想要C:\Users\admin\Pictures 所以请解决我的问题给stackoverflow团队

我正在使用此代码并收到错误....

string userpath=Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
            string Sourceurl = url;
            userpath += id;
            userpath += ".jpg";
            Bitmap varBmp = (Bitmap)Bitmap.FromStream(WebRequest.Create(url).GetResponse().GetResponseStream());
            Bitmap newBitmap = new Bitmap(varBmp);
            varBmp.Dispose();
            varBmp = null;
            //do something
            newBitmap.Save(userpath, ImageFormat.Png); 

shimpi mahesh 浦那。

4

1 回答 1

0

Try using Path.Combine as in

string userpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "123" + ".jpg");

To view the value correctly don't rely on mouse over, that shows the escaped string, to see the reality use the magnify icon near the value, a new window will appear.

于 2013-06-28T08:44:43.230 回答