Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 正在将图像文件保存到windows azure_C#_Asp.net_File Upload_Azure_Bitmap - Fatal编程技术网

C# 正在将图像文件保存到windows azure

C# 正在将图像文件保存到windows azure,c#,asp.net,file-upload,azure,bitmap,C#,Asp.net,File Upload,Azure,Bitmap,因此,我想将用户的个人资料图片保存在磁盘上。为此,我调用了SaveUserProfilePicture方法,该方法在我的本地系统上运行良好,但在Azure上运行不正常 public static string SaveUserProfilePicture(Stream image, string subDirectory) { return SaveImageFile(new Bitmap(Image.FromStream(image)), subDirectory); } priva

因此,我想将用户的个人资料图片保存在磁盘上。为此,我调用了
SaveUserProfilePicture
方法,该方法在我的本地系统上运行良好,但在Azure上运行不正常

public static string SaveUserProfilePicture(Stream image, string subDirectory)
{
    return SaveImageFile(new Bitmap(Image.FromStream(image)), subDirectory);
}

private static string SaveImageFile(Bitmap bitmap, string subDirectory)
{
    var virtualPath = string.Format("~/Images/{0}/{1}.jpg", subDirectory, Guid.NewGuid().ToString());
    bitmap.Save(HttpContext.Current.Server.MapPath(virtualPath));

    return virtualPath;
}
例外情况:

在执行当前web请求期间生成了未经处理的异常。有关异常的起源和位置的信息可以使用下面的异常堆栈跟踪来识别

[外部异常(0x80004005):GDI+中发生一般错误。] System.Drawing.Image.Save(字符串文件名、ImageCodeInfo编码器、EncoderParameters encoderParams)+473402 System.Drawing.Image.Save(字符串文件名,ImageFormat格式)+69 System.Drawing.Image.Save(字符串文件名)+25 MyProject.Core.Helpers.ImageLoader.SaveImageFile(位图,字符串子目录)+136 MyProject.Core.Helpers.ImageLoader.SaveUserProfilePicture(流图像,字符串子目录)+87 MyProject.Controller.AccountController.ChangeProfilePicture(HttpPostedFileBase选择照片)+52 lambda_方法(闭包、控制器基、对象[])+104 System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase控制器,对象[]参数)+14


我要说的是,我有一个免费的试用订阅(所以没有共享或任何东西)。此外,是否有任何方法可以查看my Azure文件夹(即图像目录下)上的文件?

您正在将其保存到本地磁盘?我建议不要那样做。您应该考虑将其保存到blob存储。可能与@Arran重复。因此,以下是windows azure网站的定价详细信息:“存储”行是否指blob存储?或者我为什么要为另一个存储环境付费?为什么我不能直接使用本地磁盘?@laszlokiss88,因为你似乎在使用Azure网站,你可以忘记我的评论。保存到本地磁盘对于网站来说很好,但是对于Azure云服务(即具有Web角色、工作人员角色等),保存到本地磁盘不是一个好主意,因为它是临时数据。你不能保证它的持久性。您的实例可能会在没有警告的情况下随时被删除,并替换为部署的新实例。因此,这是一个全新的驱动器,上面有你的网站,你已经丢失了所有的图像。但是,您可以忘记这一点:)