File not found Exception.. But it's there

前端 未结 4 926
没有蜡笔的小新
没有蜡笔的小新 2021-02-18 14:17

Hey this is going to be one of those dumb questions. I am trying to pick up a file on my local system and I keep getting a FileNotFoundException thrown.

Som

相关标签:
4条回答
  • 2021-02-18 14:52

    C:\logs\hw-healthways-prod_2009-08-26.tar should be C:\\logs\\hw-healthways-prod_2009-08-26.tar. \ means the next character is an escape character.

    0 讨论(0)
  • 2021-02-18 14:55

    Try doing Directory.GetFiles(@"C:\logs"). It's possible that the file in question has odd characters that are getting interpreted one way by Windows Explorer (presumably where you're reading "the file's property" from?) but a different way by the .NET Framework. This can happen if you have UTF-8 characters in the filename (perhaps an en dash?).

    0 讨论(0)
  • 2021-02-18 15:01

    You may want to check your file permissions. Your computer may not have permission to the file.

    0 讨论(0)
  • 2021-02-18 15:03

    May be the name of the file is "hw-healthways-prod_2009-08-26.tar.tar" instead of "hw-healthways-prod_2009-08-26.tar", I had this problem because by default the extension files are hidden on windows

    0 讨论(0)
提交回复
热议问题