Im getting error: Illegal characters in path

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
How can i remove only the Illegal characters ? Or either fix it all ?
This is the code:


<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; using System;
<span style="color:Blue; using System.Collections.Generic;
<span style="color:Blue; using System.Text;
<span style="color:Blue; using System.IO;

<span style="color:Blue; namespace ConsoleApplication1
{
<span style="color:Blue; class Program
{
<span style="color:Blue; static <span style="color:Blue; void Main(<span style="color:Blue; string[] args)
{
<span style="color:Blue; string strFilter = all_formats();
<span style="color:Blue; int y;
FileInfo fi;
<span style="color:Blue; string[] newDest_files;


newDest_files = Directory.GetFiles(Environment.CurrentDirectory, strFilter );
<span style="color:Blue; for (y = 0; y < newDest_files.Length; y++)
{
fi = <span style="color:Blue; new FileInfo(newDest_files[y]);
<span style="color:Blue; string newFolder = Path.Combine(fi.DirectoryName, fi.Name + <span style="color:#A31515; "_Directory");
<span style="color:Blue; if (!Directory.Exists(newFolder))
Directory.CreateDirectory(newFolder);
Console.WriteLine(<span style="color:#A31515; "processed: " + newDest_files.Length + <span style="color:#A31515; " files");
File.Move(fi.FullName, Path.Combine(newFolder, fi.Name));
}
<span style="color:Blue; if (newDest_files.Length == 0)
{
Console.WriteLine(<span style="color:#A31515; "No files found in the current directory! Press any key to exit...");
}
<span style="color:Blue; else
{
Console.WriteLine(<span style="color:#A31515; "Done! Press any key to exit...");
}
Console.ReadKey();



}
<span style="color:Blue; private <span style="color:Blue; static <span style="color:Blue; string all_formats()
{
<span style="color:Blue; string list_of_formats = <span style="color:#A31515; @"*.264;*.3g2;*.3gp;*.3gp;*.3gp;*.3gp;*.3mm;*.3p2;*.60d;*.787;*.aaf;*.aep;*.aep;*.aet;*.aet;*.ajp;*.ale;*.amv;*.amx;*.ani;*.arf;*.asf;*.asx;*.avb;*.avd;*.avi;*.avp;*.avs;*.avs;*.axm;*.bdm;*.bdm;*.bik;*.bin;*.bix;*.bmk;*.bnp;*.box;*.bs4;*.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
;*.rts;*.rts;*.rum;*.rv
;*.sbk;*.sbt;*.scc;*.scm;*.scm;*.scn;*.scr;*.sec;*.seq;*.sfd;*.sfv;*.smi;*.smi;*.smk;*.sml;*.smv;*.spl;*.sqz;*.srt;*.ssm;*.stl;*.str;*.stx;*.svi;*.swf;*.swi;*.swt;*.tda;*.tdx;*.tiv;*.tix;*.tod;*.tp
;*.tp0;*.tpd;*.tpr;*.trp;*.ts
;*.tvs;*.vc1;*.vcp;*.vcr;*.vcv;*.vdo;*.vdr;*.veg;*.vem;*.vf
;*.vfw;*.vfz;*.vgz;*.vid;*.vie;*.viv;*.viv;*.vla;*.vob;*.vp3;*.vp6;*.vp7;*.vpj;*.vro;*.vs4;*.vse;*.vsp;*.w32;*.wcp;*.web;*.wlm;*.wm
;*.wmd;*.wmm;*.wmv;*.wmx;*.wot;*.wp3;*.wpl;*.wtv;*.wvx;*.xfl;*.xvi;*.yuv;*.zm1;*.zm2;*.zm3;*.zmv";

<span style="color:Blue; return list_of_formats;
}
}
}


[/code]

The error is on the line: newDest_files = Directory.GetFiles(Environment.CurrentDirectory, strFilter ); on the strFilter

Thanks. <hr class="sig danieli

View the full article
 
Back
Top