在其他本地计算机中打开图像时出现问题System.ComponentModel.Win32Exception(0x80004005) [英] problem when open the image in other local machine error System.ComponentModel.Win32Exception (0x80004005)

查看:106
本文介绍了在其他本地计算机中打开图像时出现问题System.ComponentModel.Win32Exception(0x80004005)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序在其他机器上打开图像时遇到问题。错误

System.ComponentModel.Win32Exception(0x80004005):系统找不到指定的文件



i使用此代码

i have a problem when open image by my program in other machine. error
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified

i used this code

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
          
  String filepath =dataGridView1.CurrentRow.Cells[9].Value.ToString();
  paths = Application.StartupPath.Substring(0, (Application.StartupPath.Length - 10));

          string newpath = Path.GetFullPath(paths+filepath);
          Process proc = new Process();
          proc.StartInfo.FileName = (newpath);
          proc.StartInfo.UseShellExecute = true;
          proc.Start();    
                   


        }

推荐答案

您遇到的问题是文件在指定位置不存在。我没有声称文件本身不存在,我在谈论指定的位置。所以我想请你重新检查文件的位置。



如果您确定该文件存在或者您在同一文件中创建它目录,仔细检查文件名,扩展名或其他类似的东西,比如你可能想要查看的其他目录。在CodeProject上有一个类似的线程,但在.NET上下文中,你会发现一些有用的东西,系统找不到指定的文件 [ ^ ]。最后,问题是找不到(确切的)文件(你指定的)(在你希望它的确切位置)。



读/写权限没有问题,因为在这种情况下的错误是访问被拒绝
The problem that you are facing is that the file does not exist at the specified location. I am not claiming that the file itself doesn't exist, I am talking about the specified location. So I would like to ask you to re-check the location for the file.

If you are so sure that the file exists or that you created it in the same directory, double check the file name, extension or other things like are there any further directories you may want to look into. There is a similar thread to this on CodeProject, but in .NET context, you will find something useful there also, system cannot find the file specified[^]. Finally, the problem is just that the (exact) file (you specified) is not found (at the exact location you want it to be at).

There isn't a problem with read/write permissions, because the error in that case is "Access is denied".


呃......什么在地狱是这样的:

Uhhhh.... What in the hell is this:
Application.StartupPath.Substring(0, (Application.StartupPath.Length - 10))





Serisouly,阅读有关路径类 [ ^ ]。你正在使用神奇的数字做事而没有注意让你搞砸的路径内容。



不要只采取任意子串并假设它会起作用。如果文件名改变怎么办?你的代码中断。



你用来将选定的文件路径附加到你从启动路径派生的路径的方法也是可疑的。您可能没有考虑到两者之间可能缺少路径分隔符。



您对GetFullPath的使用也是可疑的。我想你不明白它到底是做什么的。



Serisouly, read the documentation on all of the methods of the Path class[^]. You're doing things using "magic numbers" and not paying attention to the contents of the path that's screwing you over.

Do NOT just take an arbitrary substring and assume that it's going to work. What if the filename changes? Your code breaks.

THe method you're using to append the selected filepath to the path you derived from startup path is also suspect. You're possibly not taking into account that you may be missing a path separator character between the two.

Your use of GetFullPath is also suspect. I think you're not understanding what it really does.


这篇关于在其他本地计算机中打开图像时出现问题System.ComponentModel.Win32Exception(0x80004005)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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