Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. 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#

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#

Scheduled Pinned Locked Moved C#
csharpcssasp-netlampsysadmin
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    ChandrakanthGaddam
    wrote on last edited by
    #1

    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

    C L 2 Replies Last reply
    0
    • C ChandrakanthGaddam

      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

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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.

      C 1 Reply Last reply
      0
      • C Christian Graus

        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.

        C Offline
        C Offline
        ChandrakanthGaddam
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • C ChandrakanthGaddam

          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

          L Offline
          L Offline
          Le centriste
          wrote on last edited by
          #4

          Looking at the length of the subject of your post, it does not surprise me you have trouble with long names. ;P

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups