GDI+、PNG 图像转 UNC 时发生一般错误
通常我不会在论坛上写东西,只是阅读我需要的信息。 这次我遇到了很大的问题,需要专家的帮助。
我想将 PictureBox 中的图像保存到文件中。
当我使用
Image.Save("X:\\Files\\logo.png");
但我需要将图像保存到 UNC 位置时它可以工作。 因此,从 X:\Files 创建了 UNC
当我尝试保存图像时,
Image.Save("\\\\\PC\\Files\\logo.png");
我收到愚蠢的 GDI+ 错误,没有任何信息。
我尝试使用 MemoryStream 保存它,但没有解决任何问题。 我尝试了 4 个小时,但没有成功。
如果我将 netvork 驱动器 \\PC\files 映射到驱动器盘符,可以说 L:\ 然后将图像另存为
Image.Save("L:\\logo.png"); // it works !
“确定”,你小子怎么了?再次..
Image.Save("X:\\Files\\logo.png"); // WORKS
Image.Save("\\\\PC\\Files\\logo.png"); // GDI+ ERROR
Image.Save("L:\\logo.png"); // DOES THE JOB (it is network drive from \\pc\files)
好吧,现在您会问我在共享文件夹上创建了哪些权限。 我添加了用户 Everyone 并设置了写入、读取和执行的权限。
问题是,实际上我想将图像保存到 NAS 驱动器,所以我不确定它具有什么 Sabma 安全权限(每个人、访客都不知道),或者换句话说,它并不像单击共享文件夹并播放那么简单具有权限..
我怎样才能解决这个有缺陷的实现?我尝试了 Image.Clone()、MemoryStrean 以及我在 Uncle Google 中找到的所有东西,但没有任何效果。我认为问题不在于无法访问的图像,但它与 UNC 位置的权限有关,但只是不知道为什么如果我在没有特殊用户登录的情况下创建网络驱动器它会起作用。我只是不能告诉客户创建网络驱动器它必须与 UNC 路径一起使用!
Ussualy I don't write stuff to forums just read info that i need.
This time I've got big problems and I need help from expert.
I would like to save image from PictureBox to file.
It works when I use
Image.Save("X:\\Files\\logo.png");
But I need to save Image to UNC location.
So created UNC from X:\Files
When I try to save Image as
Image.Save("\\\\\PC\\Files\\logo.png");
I get stupid GDI+ error without any info..
I tried saving it using MemoryStream and nothing is resolved..
I am trying it for 4hours and no sucess..
If I map netvork drive \\PC\files to drive letter lets say L:\
and then save image as
Image.Save("L:\\logo.png"); // it works !
OK what is with you boy? Again..
Image.Save("X:\\Files\\logo.png"); // WORKS
Image.Save("\\\\PC\\Files\\logo.png"); // GDI+ ERROR
Image.Save("L:\\logo.png"); // DOES THE JOB (it is network drive from \\pc\files)
Ok now you will ask me what perrmisions I created on Shared folder.
I added user Everyone and set permissions to write,read&execute.
Problem is that actually I would like to save Images to NAS drive so I am not sure what Sabma security permissions it has (everyone,guest, don't know) or in other words it is not as simple as clicking on Shared folder and play with permissions..
How can I resolve this buggy implementation? I tried Image.Clone(), MemoryStrean and all the stuff I found with Uncle Google but nothing does the job I think that problem isn't in unaccessable Image but it has something to do with permissions on UNC location but just don't know why it works if i create Network Drive with no special user login.. I just can't say to customer to create Network Drive it has to work with UNC path!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我想说你只是算错了你的反斜杠 - 应该是 4 个,而不是 5 个。尝试:
I'd say you just miscounted your backslashes - there should be 4, not 5. Try:
谢谢马克的评论。我没有 5 个反斜杠,但我做了一些更愚蠢的事情...
然后
你可以看到路径中的字符串是“\\\\PC\Files”!错误的! :=)
它必须是 \\ 所以解决方案是
在我愚蠢的文本框中输入之后的内容。
是的,我是个白痴 :=)
我确实修复了,它应该是这样的 :=)
很抱歉我在 stackoverflow 上发送了垃圾邮件。
Thank you Mark for comment.. I didn't have 5 backslashes but I did something more stupid...
and then
As you can se the string in path was "\\\\PC\Files"! Wrong! :=)
It has to be \\ so solution is
And something that follows my stupid input into text box.
Yeah I am an Idiot :=)
i did fix and it is the way it should be :=)
I am sorry that I am spamming stackoverflow.
我认为这不是代码问题,这是由于安装的组件造成的,我也遇到了同样的问题,在常规服务器上上传后自行解决。
I think it is not a code problem, it is due to installed components, I also experienced the same issue and is solved by self after uploading on a regular server.