C# Bitmap.Save 将图像保存到其他位置作为路径

发布于 2024-09-13 09:36:34 字数 259 浏览 2 评论 0原文

我正在做一个简单的图像调整大小,最后我想将其保存为:

path = "C:\\new_image.jpg";
img.Save(path, jpegCodec, encoderParams);

问题是它保存到 "....... \Users\Ervin\AppData\Local\VirtualStore\" 。 我做错了什么或者我错过了什么?

更新:我更改了其他文件夹的路径,并且它有效。看来我只能保存到 C:\ 。

I'm doing a simple image resize and on the final I want to save it like:

path = "C:\\new_image.jpg";
img.Save(path, jpegCodec, encoderParams);

The problem is it saves to "....... \Users\Ervin\AppData\Local\VirtualStore\" .
What did I do wrong or what did I miss out?

UPDATE: I changed the path to an other folder, and it works. it seems I can't save to C:\ only.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

溺ぐ爱和你が 2024-09-20 09:36:34

对此的解决方案是您正在运行的用户,因为没有直接写入 C: 驱动器的写入权限,这对 Win7 或 Vista 来说是新的,我不确定是哪一个。

您可以通过以下方法解决此问题:

  1. 保存在 C 根目录以外的目录中:
  2. 更改 C: 驱动器上的权限,以便管理员组以外的其他人具有写入权限。
  3. 以提升的权限运行您的程序。

添加 \Users\Ervin\AppData\Local\VirtualStore\ 是为了在更新时帮助修复旧版应用程序。您可能还注意到虚拟商店的“程序文件”中有很多条目。这些程序试图写入程序文件中自己的目录,而不是像它们应该的那样写入 %LOCALAPPDATA% 。

The resion for this is the user you are running as does not have write permissions to write directly to the C: drive this was new to either Win7 or Vista I am not shure which.

You can solve this by:

  1. Saving in a directory other than the root of C:
  2. Changing the permissions on the C: drive so people other than the administrators group have write access.
  3. Run your program with elevated privileges.

....... \Users\Ervin\AppData\Local\VirtualStore\ was added to help fix legacy applications when you updated. You may also notice a lot of entries in the "Program Files" in the virtual store. these are programs trying to write to their own directory in program files instead of %LOCALAPPDATA% like they should.

酒儿 2024-09-20 09:36:34

这是在 Vista 中引入的,称为虚拟化

文件虚拟化解决了
应用程序依赖的情况
关于存储文件的能力,例如
作为系统中的配置文件
位置通常只能由
管理员。运行程序作为
在这种情况下,标准用户可能会
导致程序失败的原因是
访问级别不足。

当应用程序写入系统时
位置只能写
管理员,Windows 然后写入
所有后续文件操作
Virtual 下的用户特定路径
存储目录,位于
%LOCALAPPDATA%\VirtualStore。之后,
当应用程序读回这个
文件,计算机将提供
虚拟商店中的一个。因为
Windows 安全基础设施
无需处理虚拟化
应用程序的帮助,
应用程序相信它能够
直接读写成功
到程序文件。透明度
文件虚拟化使
应用程序感知它们是
从受保护的区域写入和读取
资源,而事实上它们是
访问虚拟化版本。

This was introduced in Vista, called Virtualization:

File virtualization addresses the
situation where an application relies
on the ability to store a file, such
as a configuration file, in a system
location typically writeable only by
administrators. Running programs as a
standard user in this situation might
result in program failures due to
insufficient levels of access.

When an application writes to a system
location only writeable by
administrators, Windows then writes
all subsequent file operations to a
user-specific path under the Virtual
Store directory, which is located at
%LOCALAPPDATA%\VirtualStore. Later,
when the application reads back this
file, the computer will provide the
one in the Virtual Store. Because the
Windows security infrastructure
processes the virtualization without
the application’s assistance, the
application believes it was able to
successfully read and write directly
to Program Files. The transparency of
file virtualization enables
applications to perceive that they are
writing and reading from the protected
resource, when in fact they are
accessing the virtualized version.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文