它的文件不是foundexception [英] Its give file not foundexception

查看:53
本文介绍了它的文件不是foundexception的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码这不起作用,给一个文件找不到锄头我可以解决这个问题请帮助

my code this its not work ,give a filenot found exception hoe can i resolve this problem please help

 try
            {
                string fileName=  @"C:\Users\tnhfcl\Desktop\satya.txt ";
                
                
                StreamReader streamreader = new StreamReader(fileName);
                Console.WriteLine( streamreader.ReadToEnd());
                Console.ReadLine();
                streamreader.Close();
            }
            catch (FileNotFoundException ex)
            {
                Console.WriteLine(ex.FileName);
                Console.ReadLine();
            }
<pre>

What I have tried:

I want read this file through this code but its give a file not found exception.how can i resolve this problem

推荐答案

删除文件路径后的空格:
Remove the space after your file path:
@"C:\Users\tnhfcl\Desktop\satya.txt "


这篇关于它的文件不是foundexception的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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