The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.in C#
-
Hi, This is from Chandrakanth. working on C# with Asp.net. Actually i have one problem , That is While copying the data from Copy(Source File,DestinationFile) gettting "Ilegal charcters in a path" Actually what we are doing is Converting Tiff File To TextFile through OCR. I am getting data INTO STRING from Conversion from tiff to txt throgu OCR. And Renaming the file with .txt. And i want to move the data from STRING to txtFile. Can any one tell me what to do for that. That Code and all i am giving here . string strFilePath = FileUpload1.PostedFile.FileName; Process tessProc = new Process(); tessProc.StartInfo.WorkingDirectory = strFilePath; // @"C:\08122008_NY01_AST_1.0.tif"; // strFileName; tessProc.StartInfo.FileName = @"D:\Chandrakanth\TesseractOCR08022009\bin.dbg\tesseract.exe"; string strFileName1; int intLastIndexOfSlash; if (strFilePath.IndexOf(@"\") == 0) strFileName1 = strFilePath; else { intLastIndexOfSlash = strFilePath.LastIndexOf(@"\"); strFileName1 = strFilePath.Substring(intLastIndexOfSlash + 1); } tessProc.StartInfo.Arguments = strFileName1 + " output"; tessProc.Start(); string output = File.ReadAllText(@"C:\output.txt"); TextBox1.Text = output; string strOutPutFileName = System.IO.Path.GetFileNameWithoutExtension (strFileName1) + ".TXT"; string strSaveFilePath = Server.MapPath(""); File.Create(strSaveFilePath + @"\" + strOutPutFileName); string illegal = output; string regexSearch = string.Format("{0}{1}", new string(Path.GetInvalidFileNameChars()), new string(Path.GetInvalidPathChars())); Regex r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch))); illegal = r.Replace(illegal, ""); System.IO.File.Copy(illegal, strOutPutFileName); Actually that illegal contains data in below format ------------------------------------------------------------------------ JMW -J 'me l^ T l ii T T ASTER ^ WE INTEGRATE CDMIUIYICJTIOIVS INVOIC E ASTER TELE SERVICES FVT. LTD, Invoice No: EMHASDCGSE Flat na.4 to 7, C/a Krlshna Plaza, Date: 13-Dec417 , Opp.WaLer Tanks, Near TATA Garden Busstop, . Chandan Nagar, PUNE-14 PAN No AACCA54E9L P.O.NG: 4352 CST TIN is 2715000524SC w e.l01 04.2005 Date: MAMGY-W \lAT TIN is 2715000524GV wel`01 O4 ZODG ST Regn No. AACCAMSBLSTOUT Kg Vodafnile Essar Cellular Lid., .)Mutropnlltan, F/P Null. S,No. 21, Old Mumbalrvurla Highway, Wakzdewadljhivaji Nagar, Site Name: Gad Mudslngi PUNE 7 411005 TowsrType R1~l Tower Height: 21 Mts Natllreof Workmvaition Lamp, Llghting Arrester E
-
Hi, This is from Chandrakanth. working on C# with Asp.net. Actually i have one problem , That is While copying the data from Copy(Source File,DestinationFile) gettting "Ilegal charcters in a path" Actually what we are doing is Converting Tiff File To TextFile through OCR. I am getting data INTO STRING from Conversion from tiff to txt throgu OCR. And Renaming the file with .txt. And i want to move the data from STRING to txtFile. Can any one tell me what to do for that. That Code and all i am giving here . string strFilePath = FileUpload1.PostedFile.FileName; Process tessProc = new Process(); tessProc.StartInfo.WorkingDirectory = strFilePath; // @"C:\08122008_NY01_AST_1.0.tif"; // strFileName; tessProc.StartInfo.FileName = @"D:\Chandrakanth\TesseractOCR08022009\bin.dbg\tesseract.exe"; string strFileName1; int intLastIndexOfSlash; if (strFilePath.IndexOf(@"\") == 0) strFileName1 = strFilePath; else { intLastIndexOfSlash = strFilePath.LastIndexOf(@"\"); strFileName1 = strFilePath.Substring(intLastIndexOfSlash + 1); } tessProc.StartInfo.Arguments = strFileName1 + " output"; tessProc.Start(); string output = File.ReadAllText(@"C:\output.txt"); TextBox1.Text = output; string strOutPutFileName = System.IO.Path.GetFileNameWithoutExtension (strFileName1) + ".TXT"; string strSaveFilePath = Server.MapPath(""); File.Create(strSaveFilePath + @"\" + strOutPutFileName); string illegal = output; string regexSearch = string.Format("{0}{1}", new string(Path.GetInvalidFileNameChars()), new string(Path.GetInvalidPathChars())); Regex r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch))); illegal = r.Replace(illegal, ""); System.IO.File.Copy(illegal, strOutPutFileName); Actually that illegal contains data in below format ------------------------------------------------------------------------ JMW -J 'me l^ T l ii T T ASTER ^ WE INTEGRATE CDMIUIYICJTIOIVS INVOIC E ASTER TELE SERVICES FVT. LTD, Invoice No: EMHASDCGSE Flat na.4 to 7, C/a Krlshna Plaza, Date: 13-Dec417 , Opp.WaLer Tanks, Near TATA Garden Busstop, . Chandan Nagar, PUNE-14 PAN No AACCA54E9L P.O.NG: 4352 CST TIN is 2715000524SC w e.l01 04.2005 Date: MAMGY-W \lAT TIN is 2715000524GV wel`01 O4 ZODG ST Regn No. AACCAMSBLSTOUT Kg Vodafnile Essar Cellular Lid., .)Mutropnlltan, F/P Null. S,No. 21, Old Mumbalrvurla Highway, Wakzdewadljhivaji Nagar, Site Name: Gad Mudslngi PUNE 7 411005 TowsrType R1~l Tower Height: 21 Mts Natllreof Workmvaition Lamp, Llghting Arrester E
chandragaddam wrote:
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
Can you confirm that your path and filename are NOT that long ? Or does the error mean what it says ?
Christian Graus Driven to the arms of OSX by Vista.
-
chandragaddam wrote:
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
Can you confirm that your path and filename are NOT that long ? Or does the error mean what it says ?
Christian Graus Driven to the arms of OSX by Vista.
Hi, Once again from Chandrakanth. That file name is in the format of (Tiff File)-- 08122008_NY01_AST_3.0.tif After Conversion the file will be going to change like 08122008_NY01_AST_3.0.txt. .txt file is going to store in Application directory. The Application directory is in "D:\Chandrakanth\TesseractOCR08022009" That application name is "TesseractOCR08022009" And that illegal contains Data. I want to move that to "08122008_NY01_AST_3.0.txt." this txtfile. While moving data i am getting error. Could u pls give me some response on thar ASAP. Thanks and Regards Chandrakanth
-
Hi, This is from Chandrakanth. working on C# with Asp.net. Actually i have one problem , That is While copying the data from Copy(Source File,DestinationFile) gettting "Ilegal charcters in a path" Actually what we are doing is Converting Tiff File To TextFile through OCR. I am getting data INTO STRING from Conversion from tiff to txt throgu OCR. And Renaming the file with .txt. And i want to move the data from STRING to txtFile. Can any one tell me what to do for that. That Code and all i am giving here . string strFilePath = FileUpload1.PostedFile.FileName; Process tessProc = new Process(); tessProc.StartInfo.WorkingDirectory = strFilePath; // @"C:\08122008_NY01_AST_1.0.tif"; // strFileName; tessProc.StartInfo.FileName = @"D:\Chandrakanth\TesseractOCR08022009\bin.dbg\tesseract.exe"; string strFileName1; int intLastIndexOfSlash; if (strFilePath.IndexOf(@"\") == 0) strFileName1 = strFilePath; else { intLastIndexOfSlash = strFilePath.LastIndexOf(@"\"); strFileName1 = strFilePath.Substring(intLastIndexOfSlash + 1); } tessProc.StartInfo.Arguments = strFileName1 + " output"; tessProc.Start(); string output = File.ReadAllText(@"C:\output.txt"); TextBox1.Text = output; string strOutPutFileName = System.IO.Path.GetFileNameWithoutExtension (strFileName1) + ".TXT"; string strSaveFilePath = Server.MapPath(""); File.Create(strSaveFilePath + @"\" + strOutPutFileName); string illegal = output; string regexSearch = string.Format("{0}{1}", new string(Path.GetInvalidFileNameChars()), new string(Path.GetInvalidPathChars())); Regex r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch))); illegal = r.Replace(illegal, ""); System.IO.File.Copy(illegal, strOutPutFileName); Actually that illegal contains data in below format ------------------------------------------------------------------------ JMW -J 'me l^ T l ii T T ASTER ^ WE INTEGRATE CDMIUIYICJTIOIVS INVOIC E ASTER TELE SERVICES FVT. LTD, Invoice No: EMHASDCGSE Flat na.4 to 7, C/a Krlshna Plaza, Date: 13-Dec417 , Opp.WaLer Tanks, Near TATA Garden Busstop, . Chandan Nagar, PUNE-14 PAN No AACCA54E9L P.O.NG: 4352 CST TIN is 2715000524SC w e.l01 04.2005 Date: MAMGY-W \lAT TIN is 2715000524GV wel`01 O4 ZODG ST Regn No. AACCAMSBLSTOUT Kg Vodafnile Essar Cellular Lid., .)Mutropnlltan, F/P Null. S,No. 21, Old Mumbalrvurla Highway, Wakzdewadljhivaji Nagar, Site Name: Gad Mudslngi PUNE 7 411005 TowsrType R1~l Tower Height: 21 Mts Natllreof Workmvaition Lamp, Llghting Arrester E
Looking at the length of the subject of your post, it does not surprise me you have trouble with long names. ;P