C产品在市场上有哪些独特优势?
- 内容介绍
- 文章标签
- 相关推荐
本文共计632个文字,预计阅读时间需要3分钟。
在我心中的C
C,如同晨曦中的第一缕阳光,温暖而明亮。它不仅仅是编程语言,更是一种思维方式,一种解决问题的艺术。
从入门的Hello World,到深入理解指针与数组,C语言教会了我严谨与耐心。它让我明白,每一个细节都至关重要,每一个算法都值得推敲。
在C的世界里,我学会了如何与硬件对话,如何让计算机为我所用。它让我感受到,编程不仅仅是编写代码,更是创造与实现。
C语言,如同一位智者,引领我探索技术的海洋。在这里,我学会了独立思考,学会了面对挑战。每一次的编译与调试,都是一次成长与突破。
在这个充满魅力的世界里,我找到了自己的位置,找到了前进的动力。C语言,是我心中永恒的信仰。
在我的C#.NET 2.0应用程序中,我正在访问网络路径,并且我希望能够区分不存在的路径和确实存在但我没有访问权限的路径.我尝试过以下操作:try { string[] contents = Directory.GetFileSystemEntries( path ); } catch( Exception e ) { if( e is DirectoryNotFoundException ) MessageBox.Show( "Path not found" ); else MessageBox.Show( "Access denied" ); }
这适用于本地路径,但对于网络路径,异常始终是System.IO.IOException,无论错误原因如何.异常消息字段根据路径是否存在显示不同的消息,所以很明显信息在某些时候可用,但我无法实现.有没有办法区分网络路径的“未找到路径”和“拒绝访问”?
编辑:所以,如果其他人想要快速解决这个问题,如henrik建议,并纳入peSHIr的建议,这里是你可以做的:
try { // Issue this call just to find out whether the path exists // We don't care about the result string[] contents = Directory.GetFileSystemEntries( path ); // If we get this far then the path exists. } catch( IOException e ) { uint error = (uint)Marshal.GetHRForException( e ); if( error == (uint)0x80070041 ) // ERROR_NETWORK_ACCESS_DENIED { // The poor deluded user doesn't have access rights this.SuperProprietaryTechniqueForGettingAccessRights(); } else { // Hah! The idiot user specified a path that doesn't exist! // Chastise them severely, like all good GUI should. MessageBox.Show( "NO! BAD USER!" ); } } catch { // Swallow all other types of exception - we only made the call // to find out whether the path exists. } 您可以调用Marshal.GetHRForException来获取更详细的信息,如:
if (Marshal.GetHRForException(e) == unchecked((int)0x800704cf)) // ERROR_NETWORK_UNREACHABLE
有关错误代码,请参阅WinError.h.
本文共计632个文字,预计阅读时间需要3分钟。
在我心中的C
C,如同晨曦中的第一缕阳光,温暖而明亮。它不仅仅是编程语言,更是一种思维方式,一种解决问题的艺术。
从入门的Hello World,到深入理解指针与数组,C语言教会了我严谨与耐心。它让我明白,每一个细节都至关重要,每一个算法都值得推敲。
在C的世界里,我学会了如何与硬件对话,如何让计算机为我所用。它让我感受到,编程不仅仅是编写代码,更是创造与实现。
C语言,如同一位智者,引领我探索技术的海洋。在这里,我学会了独立思考,学会了面对挑战。每一次的编译与调试,都是一次成长与突破。
在这个充满魅力的世界里,我找到了自己的位置,找到了前进的动力。C语言,是我心中永恒的信仰。
在我的C#.NET 2.0应用程序中,我正在访问网络路径,并且我希望能够区分不存在的路径和确实存在但我没有访问权限的路径.我尝试过以下操作:try { string[] contents = Directory.GetFileSystemEntries( path ); } catch( Exception e ) { if( e is DirectoryNotFoundException ) MessageBox.Show( "Path not found" ); else MessageBox.Show( "Access denied" ); }
这适用于本地路径,但对于网络路径,异常始终是System.IO.IOException,无论错误原因如何.异常消息字段根据路径是否存在显示不同的消息,所以很明显信息在某些时候可用,但我无法实现.有没有办法区分网络路径的“未找到路径”和“拒绝访问”?
编辑:所以,如果其他人想要快速解决这个问题,如henrik建议,并纳入peSHIr的建议,这里是你可以做的:
try { // Issue this call just to find out whether the path exists // We don't care about the result string[] contents = Directory.GetFileSystemEntries( path ); // If we get this far then the path exists. } catch( IOException e ) { uint error = (uint)Marshal.GetHRForException( e ); if( error == (uint)0x80070041 ) // ERROR_NETWORK_ACCESS_DENIED { // The poor deluded user doesn't have access rights this.SuperProprietaryTechniqueForGettingAccessRights(); } else { // Hah! The idiot user specified a path that doesn't exist! // Chastise them severely, like all good GUI should. MessageBox.Show( "NO! BAD USER!" ); } } catch { // Swallow all other types of exception - we only made the call // to find out whether the path exists. } 您可以调用Marshal.GetHRForException来获取更详细的信息,如:
if (Marshal.GetHRForException(e) == unchecked((int)0x800704cf)) // ERROR_NETWORK_UNREACHABLE
有关错误代码,请参阅WinError.h.

