如果File.Exists Else问题

编程入门 行业动态 更新时间:2024-10-28 10:36:10
本文介绍了如果File.Exists Else问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如果我在VB.NET表单中使用下面的代码,即使文件存在,然后执行 ,Else语句也会生成抱歉找不到文件 错误信息。 永远不会调用MessageBox.Show(StrPathToScript)!为什么? 如果File.Exists(StrPathToScript)那么 MessageBox.Show(StrPathToScript) Else MessageBox.Show(抱歉找不到文件) 结束如果 提前致谢 Joseph

If I use the code below in a VB.NET form, even if the file exists, and is then executed, the Else statement produces the "Sorry cannot find the File " error message. The MessageBox.Show( StrPathToScript ) never gets called! why? If File.Exists( StrPathToScript ) Then MessageBox.Show( StrPathToScript ) Else MessageBox.Show( "Sorry cannot find the File " ) End If Thanks in advance Joseph

推荐答案

Joseph, 来自MSDN文档:如果调用者没有足够的权限来读取指定的文件,则不会抛出任何异常并且方法返回false 无论路径是否存在 这可能是你的问题吗? - Carsten Thomsen 社区 - community.integratedsolutions.dk " Joseph Oget" < pH值********** @ hotmail>在消息中写道 新闻:eK ************** @ TK2MSFTNGP14.phx.gbl ... Joseph, From the MSDN docs: "If the caller does not have sufficient permissions to read the specified file, no exception is thrown and the method returns false regardless of the existence of path" Could that be your problem? -- Carsten Thomsen Communities - community.integratedsolutions.dk "Joseph Oget" <ph**********@hotmail> wrote in message news:eK**************@TK2MSFTNGP14.phx.gbl... 如果我使用代码在VB.NET表单下面,即使该文件存在,然后执行,Else语句也会生成抱歉找不到文件。错误信息。 MessageBox.Show(StrPathToScript)永远不会被调用!为什么? 如果File.Exists(StrPathToScript)那么就是MessageBox.Show(StrPathToScript) 另外的消息盒.Show(抱歉找不到文件) 结束如果 提前致谢 Joseph If I use the code below in a VB.NET form, even if the file exists, and is then executed, the Else statement produces the "Sorry cannot find the File " error message. The MessageBox.Show( StrPathToScript ) never gets called! why? If File.Exists( StrPathToScript ) Then MessageBox.Show( StrPathToScript ) Else MessageBox.Show( "Sorry cannot find the File " ) End If Thanks in advance Joseph

你好CT, 我试图检查的文件我的电脑本地存在,并且在汇编所在的 文件夹中,所以我试图以任何方式打开它, 只检查如果它存在或不存在。 Joseph " CT" < CA ****** @ spammersgoawayintegrasol.dk>在消息中写道 新闻:O2 ************* @ TK2MSFTNGP09.phx.gbl ... Hi CT, Thanks for your reply. The file I attempt to check the existence of, is local to my PC, and in a folder below where the assembly is, so I do attempt to open it in any way, only to check if it exist or not. Joseph "CT" <ca******@spammersgoawayintegrasol.dk> wrote in message news:O2*************@TK2MSFTNGP09.phx.gbl... Joseph, 来自MSDN文档:如果调用者没有足够的权限来读取指定的文件,则不会抛出任何异常,并且无论路径是否存在,该方法都返回 br /> 这可能是你的问题吗? - Carsten Thomsen 社区 - community.integratedsolutions.dk Joseph Oget < pH值********** @ hotmail>在消息中写道新闻:eK ************** @ TK2MSFTNGP14.phx.gbl ... Joseph, From the MSDN docs: "If the caller does not have sufficient permissions to read the specified file, no exception is thrown and the method returns false regardless of the existence of path" Could that be your problem? -- Carsten Thomsen Communities - community.integratedsolutions.dk "Joseph Oget" <ph**********@hotmail> wrote in message news:eK**************@TK2MSFTNGP14.phx.gbl... 如果我在VB中使用下面的代码.NET表单,即使文件存在,然后执行,Else语句也会生成抱歉无法找到文件。错误信息。 MessageBox.Show(StrPathToScript)永远不会被调用!为什么? 如果File.Exists(StrPathToScript)那么就是MessageBox.Show(StrPathToScript) 另外的消息盒.Show(抱歉找不到文件) 结束如果 提前致谢 Joseph If I use the code below in a VB.NET form, even if the file exists, and is then executed, the Else statement produces the "Sorry cannot find the File " error message. The MessageBox.Show( StrPathToScript ) never gets called! why? If File.Exists( StrPathToScript ) Then MessageBox.Show( StrPathToScript ) Else MessageBox.Show( "Sorry cannot find the File " ) End If Thanks in advance Joseph

即使现在或现在也可能没有足够的权利。 如何处理异常?否则我会仔细查看路径并尝试 a位置,我确定没有问题... - Patrice " Joseph Oget" < pH值********** @ hotmail>一个écritdansle message de 新闻:O9 **************** @ TK2MSFTNGP15.phx.gbl ... Could also not have sufficient rights to even now if it exists or now. How do you handle exceptions ? Else I would double check the path and would try a location where I''m sure there is no problems... -- Patrice "Joseph Oget" <ph**********@hotmail> a écrit dans le message de news:O9****************@TK2MSFTNGP15.phx.gbl... 您好CT, 感谢您的回复。 我试图检查存在的文件是我的电脑本地文件,并在下面的文件夹中组装是,所以我试图以任何方式打开它,只检查它是否存在。 约瑟夫CT < CA ****** @ spammersgoawayintegrasol.dk>在消息中写道新闻:O2 ************* @ TK2MSFTNGP09.phx.gbl ... Hi CT, Thanks for your reply. The file I attempt to check the existence of, is local to my PC, and in a folder below where the assembly is, so I do attempt to open it in any way, only to check if it exist or not. Joseph "CT" <ca******@spammersgoawayintegrasol.dk> wrote in message news:O2*************@TK2MSFTNGP09.phx.gbl... Joseph, 从MSDN文档中:如果调用者没有足够的权限来读取指定的文件,则不会抛出任何异常,并且无论路径是否存在,该方法都会返回错误 <这可能是你的问题吗? - Carsten Thomsen 社区 - community.integratedsolutions.dk Joseph Oget < pH值********** @ hotmail>在消息中写道新闻:eK ************** @ TK2MSFTNGP14.phx.gbl ... Joseph, From the MSDN docs: "If the caller does not have sufficient permissions to read the specified file, no exception is thrown and the method returns false regardless of the existence of path" Could that be your problem? -- Carsten Thomsen Communities - community.integratedsolutions.dk "Joseph Oget" <ph**********@hotmail> wrote in message news:eK**************@TK2MSFTNGP14.phx.gbl... 如果我在VB中使用下面的代码.NET表单,即使该文件存在,然后执行,Else语句也会生成抱歉找不到文件。错误信息。 MessageBox.Show(StrPathToScript)永远不会被调用!为什么? 如果File.Exists(StrPathToScript)那么就是MessageBox.Show(StrPathToScript) 另外的消息盒.Show(抱歉找不到文件) 结束如果 提前致谢 Joseph If I use the code below in a VB.NET form, even if the file exists, and is then executed, the Else statement produces the "Sorry cannot find the File " error message. The MessageBox.Show( StrPathToScript ) never gets called! why? If File.Exists( StrPathToScript ) Then MessageBox.Show( StrPathToScript ) Else MessageBox.Show( "Sorry cannot find the File " ) End If Thanks in advance Joseph

更多推荐

如果File.Exists Else问题

本文发布于:2023-06-08 14:31:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/583115.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:File   Exists

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!