将图像保存在文件夹中 [英] Save the image in the folder

查看:85
本文介绍了将图像保存在文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用C#将图像保存在asp.net中



当我运行本地计算机时,图像会保存。



但是当我在服务器中运行时出现如下错误:



我的代码如下:



Save the image in asp.net using C#

When i run the local machine the image saves.

But when i run in the server error shows as follows:

My code as follows:

Bitmap bitmap = new Bitmap(990, 540);
            Graphics graphics = Graphics.FromImage(bitmap as System.Drawing.Image);
            graphics.CopyFromScreen(5, 160, 0, 0, bitmap.Size);
            bitmap.Save(@"\\director\transfer\staff\NIRANJAN\" + ddlSession.Text.ToString().Trim() + "DailySchedule.bmp", ImageFormat.Bmp);





错误显示如下:



异常详细信息:System.ComponentModel.Win32Exception:

句柄无效



第35行:graphics.CopyFromScreen(5,160, 0,0,bitmap.Size);



请帮帮我。



有什么问题< br $>


问候,

Narasiman P.



The error shows as follows:

Exception Details: System.ComponentModel.Win32Exception:
The handle is invalid

Line 35: graphics.CopyFromScreen(5, 160, 0, 0, bitmap.Size);

please help me.

what is the problem

Regards,
Narasiman P.

推荐答案

可能是远射 -



此功能从设备上下文复制。

当屏幕锁定时,桌面图像可能不存在于任何地方,

检查sc时是否抛出此异常reen被锁定了...(你确实在这个服务器上使用了一个屏幕吗?)
Might be a long shot -

This function copies from a Device Context.
When the screen is locked, the image of the desktop might not exist anywhere,
Check if this exception is thrown when the screen is locked... (you do use a screen on this server do you?)


你有权限吗?在本地计算机上,您可能拥有文件夹结构C:\Director \Transfer \Staff \ Niranjan \的完全权限,但在生产服务器上,它可能会被更严格地锁定。检查路径中的每个文件夹是否都存在于服务器上,并且给出了相应的权限。



另外一件事 - 你不希望这样做客户端PC的快照,是吗?因为它会在您的开发机器上......但是它没有机会在生产中工作,其中服务器和客户端是独立的机器!
Do you have permission? On your local machine, you probably have full permission for the folder structure "C:\Director\Transfer\Staff\Niranjan\" but on the production server it is likely to be more tightly locked down. Check that every folder in the path exists on the server, and that the appropriate permissions are given.

And the other thing - you aren't expecting this to take a snapshot of the client PC, are you? Because it will, on your development machine...but there is not a chance in heck of it working in production where the server and client are separate machines!


这篇关于将图像保存在文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆