<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Check Valid File Path in C#</title>
	<atom:link href="http://www.csharp411.com/check-valid-file-path-in-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.csharp411.com/check-valid-file-path-in-c/</link>
	<description>C# Information, Code, Tips and News</description>
	<lastBuildDate>Sat, 24 Jul 2010 01:26:51 -0400</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Imi</title>
		<link>http://www.csharp411.com/check-valid-file-path-in-c/comment-page-1/#comment-5555</link>
		<dc:creator>Imi</dc:creator>
		<pubDate>Fri, 02 Jul 2010 12:07:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.csharp411.com/check-valid-file-path-in-c/#comment-5555</guid>
		<description>Remember, that there are special files under windows which cannot be created (or have undesired effects when attempting to) and whose characters are not in Path.InvalidFileNameChars

For example files named &quot;COM1&quot;, &quot;PRN&quot; or just &quot;NUL&quot;.

Look here: http://social.technet.microsoft.com/Forums/en/w7itprogeneral/thread/e22c021d-d188-4ff2-a4dd-b5d58d979c58</description>
		<content:encoded><![CDATA[<p>Remember, that there are special files under windows which cannot be created (or have undesired effects when attempting to) and whose characters are not in Path.InvalidFileNameChars</p>
<p>For example files named "COM1&#8243;, "PRN" or just "NUL".</p>
<p>Look here: <a href="http://social.technet.microsoft.com/Forums/en/w7itprogeneral/thread/e22c021d-d188-4ff2-a4dd-b5d58d979c58" rel="nofollow">http://social.technet.microsoft.com/Forums/en/w7itprogeneral/thread/e22c021d-d188-4ff2-a4dd-b5d58d979c58</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: srikanth.gaddala</title>
		<link>http://www.csharp411.com/check-valid-file-path-in-c/comment-page-1/#comment-5244</link>
		<dc:creator>srikanth.gaddala</dc:creator>
		<pubDate>Fri, 24 Jul 2009 12:17:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.csharp411.com/check-valid-file-path-in-c/#comment-5244</guid>
		<description>hi Robin,
 the code you have provided for RemoveInvalidFileNameChars()
is really very useful to me.
thanks a lot...



Srikanth.g</description>
		<content:encoded><![CDATA[<p>hi Robin,<br />
 the code you have provided for RemoveInvalidFileNameChars()<br />
is really very useful to me.<br />
thanks a lot&#8230;</p>
<p>Srikanth.g</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Romy</title>
		<link>http://www.csharp411.com/check-valid-file-path-in-c/comment-page-1/#comment-4492</link>
		<dc:creator>Romy</dc:creator>
		<pubDate>Wed, 25 Mar 2009 16:33:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.csharp411.com/check-valid-file-path-in-c/#comment-4492</guid>
		<description>Try:
 private static void CheckValidPath(string pathFile)
 {
   string fullPath = pathFile;
   FileIOPermission permission = new FileIOPermission(PermissionState.None);
   permission.AllFiles = FileIOPermissionAccess.PathDiscovery;
   permission.Assert();
   try { fullPath = Path.GetFullPath(pathFile); }
   finally { CodeAccessPermission.RevertAssert(); }

   FileIOPermission checkFile = new FileIOPermission(FileIOPermissionAccess.AllAccess, fullPath);
   checkFile.Demand();
 }

Regards,
Romy</description>
		<content:encoded><![CDATA[<p>Try:<br />
 private static void CheckValidPath(string pathFile)<br />
 {<br />
   string fullPath = pathFile;<br />
   FileIOPermission permission = new FileIOPermission(PermissionState.None);<br />
   permission.AllFiles = FileIOPermissionAccess.PathDiscovery;<br />
   permission.Assert();<br />
   try { fullPath = Path.GetFullPath(pathFile); }<br />
   finally { CodeAccessPermission.RevertAssert(); }</p>
<p>   FileIOPermission checkFile = new FileIOPermission(FileIOPermissionAccess.AllAccess, fullPath);<br />
   checkFile.Demand();<br />
 }</p>
<p>Regards,<br />
Romy</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robin</title>
		<link>http://www.csharp411.com/check-valid-file-path-in-c/comment-page-1/#comment-4140</link>
		<dc:creator>Robin</dc:creator>
		<pubDate>Sun, 25 Jan 2009 13:12:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.csharp411.com/check-valid-file-path-in-c/#comment-4140</guid>
		<description>To get a valid FILE NAME after removing the Invalid file name characters, you can use the following  function.

public static string RemoveInvalidFileNameChars(string fileName)
    {
        char[] invalidFileChars = Path.GetInvalidFileNameChars();

        foreach (char invalidFChar in invalidFileChars)
        {
            fileName = fileName.Replace(invalidFChar.ToString(),&quot;&quot;);
        }
        return fileName;

    }</description>
		<content:encoded><![CDATA[<p>To get a valid FILE NAME after removing the Invalid file name characters, you can use the following  function.</p>
<p>public static string RemoveInvalidFileNameChars(string fileName)<br />
    {<br />
        char[] invalidFileChars = Path.GetInvalidFileNameChars();</p>
<p>        foreach (char invalidFChar in invalidFileChars)<br />
        {<br />
            fileName = fileName.Replace(invalidFChar.ToString(),"");<br />
        }<br />
        return fileName;</p>
<p>    }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tk</title>
		<link>http://www.csharp411.com/check-valid-file-path-in-c/comment-page-1/#comment-3316</link>
		<dc:creator>tk</dc:creator>
		<pubDate>Wed, 17 Sep 2008 12:39:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.csharp411.com/check-valid-file-path-in-c/#comment-3316</guid>
		<description>&gt;will validate an absolute file path on a Windows PC in most cases

An obvious execption is filenames in non-English
(ie other characters than a-z)

Still, thanks :)</description>
		<content:encoded><![CDATA[<p>&gt;will validate an absolute file path on a Windows PC in most cases</p>
<p>An obvious execption is filenames in non-English<br />
(ie other characters than a-z)</p>
<p>Still, thanks <img src='http://www.csharp411.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
