Could Not Find File Error C#
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more c# streamreader could not find file about Stack Overflow the company Business Learn more about hiring developers or posting could not find file filestream c# ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack c# file not found but exists Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Why am I getting “could not find file '\[filename]'”? up vote
Filenotfoundexception C# Example
0 down vote favorite With this code: private void menuItem2_Click(object sender, System.EventArgs e) { String xmlFile = "DuckbilledPlatypiGuy.xml"; String uri = "http://192.168.125.50:21608/api/inventory/sendXML/duckbill/platypus/testfyle"; RESTfulMethods rm = new RESTfulMethods(); rm.SendXMLFile(xmlFile, uri, 500); } public void SendXMLFile(string xmlFilepath, string uri, int timeout) { StringBuilder sb = new StringBuilder(); using (StreamReader sr = new StreamReader(xmlFilepath)) { . . . ...I'm getting, "Could not find file '\DuckbilledPlatypiGuy.xml'" Why is it prepending a backwhack to c# could not find file the file name? Is that the problem and if so, how do I prevent it? The file is in the same folder as the .exe, so it should be in plain sight. UPDATE I tried this: String xmlFile = "\\DuckbilledPlatypiGuy.xml"; ...but it makes no difference - still get, "Could not find file '\DuckbilledPlatypiGuy.xml'" So whether I give the file name no whacks or two, it still seems to think it has one. Also tried the following, with the same result: String xmlFile = @"DuckbilledPlatypiGuy.xml"; UPDATE 2 After finding this in my .NET Compact Framework book (p. 338, the book written by Andy Wigley): StreamReader myReader = new StreamReader("\\myFile.txt"); ...I tried this: using (StreamReader sr = new StreamReader("\\" + xmlFilepath)) ...and even this: using (StreamReader sr = new StreamReader("\\DuckbilledPlatypiGuy.xml")) ...but I still get that same err msg. UPDATE 3 If I do this: String fallName = String.Format("\\{0}", xmlFilepath); MessageBox.Show(String.Format("fallName is {0}", fallName)); using (StreamReader sr = new StreamReader(fallName)) ...I see "fallName is '\DuckbilledPlatypiGuy.xml'" and I get the same old err msg. If I do this (it seems to expect doubled backwhacks prepended to the filename): String fallName = String.Format("\\\\{0}", xmlFilepath); MessageBox.Show(String.Format("fallName is {0}", fallName)); using (StreamReader sr = new StreamReader(fallName)) ...I see "fallName is '\DuckbilledPlatypiGuy.xml'"
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and file not found c# policies of this site About Us Learn more about Stack Overflow the
Could Not Find A Part Of The Path
company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags
Visual Studio Could Not Find File
Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only http://stackoverflow.com/questions/25857681/why-am-i-getting-could-not-find-file-filename takes a minute: Sign up “Could not find a part of the path” error message up vote 4 down vote favorite 1 I am programming in c# and want to copy a folder with subfolders from a flash disk to startup. Here is my code: private void copyBat() { try { string source_dir = "E:\\Debug\\VipBat"; string destination_dir = "C:\\Users\\pc\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup"; if http://stackoverflow.com/questions/21796687/could-not-find-a-part-of-the-path-error-message (!System.IO.Directory.Exists(destination_dir)) { System.IO.Directory.CreateDirectory(destination_dir); } // Create subdirectory structure in destination foreach (string dir in Directory.GetDirectories(source_dir, "*", System.IO.SearchOption.AllDirectories)) { Directory.CreateDirectory(destination_dir + dir.Substring(source_dir.Length)); } foreach (string file_name in Directory.GetFiles(source_dir, "*.*", System.IO.SearchOption.AllDirectories)) { File.Copy(file_name, destination_dir + file_name.Substring(source_dir.Length), true); } } catch (Exception e) { MessageBox.Show(e.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } I got an error: Could not find a part of the path E:\Debug\VipBat Thank you for your Help.... c# file-io share|improve this question edited Feb 15 '14 at 13:37 asked Feb 15 '14 at 11:10 user3313131 45127 Why the {0} ? –Ofiris Feb 15 '14 at 11:13 2 You are using verbatim string literals @"" in which case you don't need to escape out `\` - just use a single slash. –StuartLC Feb 15 '14 at 11:13 @StuartLC is right. If you use verbatim string literal, your string will be exactly as what you write. In this case, it will be exactly E:\\Debug\\VipBat\\ which is not a valid path. –Soner Gönül Feb 15 '14 at 11:14 Shouldn't you fill {0} present in E:\\Debug\\VipBat\\{0}? Another thing
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners https://msdn.microsoft.com/en-us/library/bk2k9wf5(v=vs.80).aspx ISV Startups TechRewards Events Community Magazine Forums Blogs Channel http://forum.unity3d.com/threads/c-could-not-find-file.131466/ 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. Integrated Development Environment for Visual Studio Deploying Applications and Components Deployment Error Messages could not Deployment Error Messages Could not find file '
Forums Answers Feedback Issue Tracker Blog Evangelists User Groups Navigation Home Unity Services Made with Unity Learn Community Forums Answers Feedback Issue Tracker Blog Evangelists User Groups Asset Store Get Unity Unity Account You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account Language 中文 한국어 Portugués Русский Español 日本語 Unity Community Forums Forums Forums Quick Links Search Forums Recent Posts Menu The 5.5 Beta is now available. Click here for more details! Get early access to our Google Daydream Technical preview. Click here for more details! Become a closed-alpha partner on the new Facebook games platform. Read more about it here. Enter the Samsung TIZEN App Challenge for a chance to win prizes. Read more about it here. Download the 5.5 Beta Now Daydream Preview New Facebook Games Platform Samsung TIZEN App Challenge Unity Community - Error unity_authentication_failed Your name or email address: Password: Forgot your password? Stay logged in