locked
asp.net to read PDF RRS feed

  • Question

  • User1888449941 posted

    I would like to know if it's possible for asp.net to read a PDF file and search for specific values like: "user " and "userid" so it can properly upload it to a database based on these credentials OR if the PDF file was named: "user - userid" would it be possible to read the file and extract "user" and "userid" as two different values fromt he file's name? I hope I am making sense here

    Thursday, April 9, 2009 3:45 PM

Answers

  • User1306565749 posted

    Hi,

    If your pdf file name is like 'user-userID' then it is very easy to read filename and split it according to ur need.

    use

    System.IO.FileInfo class to get the fileName. after that parse the file name for username and userid

    Please mark this post as a answer, if this post helps

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 10, 2009 5:54 AM
  • User1306565749 posted

    Hi,
    System.IO.FileInfo f =  new System.IO.FileInfo("c:\\YServer.txt");          
    String textFile = f.Name;
    String [] arr = textFile.Split('.');

    String FileNAme = arr[0];
    String ext = arr[1]; //please chek for the correct array index, this code has some risk, you may get array out of range/null reference exception

    OR you do it in another way

    String extension = textFile.Substring(textFile.LastIndexOf('.')+1);

    http://msdn.microsoft.com/en-us/library/system.string.split.aspx

    Please Mark This Post as Answer, if it helped

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 15, 2009 5:37 AM

All replies

  • User1306565749 posted

    Hi,

    If your pdf file name is like 'user-userID' then it is very easy to read filename and split it according to ur need.

    use

    System.IO.FileInfo class to get the fileName. after that parse the file name for username and userid

    Please mark this post as a answer, if this post helps

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 10, 2009 5:54 AM
  • User1888449941 posted

     any suggestions / links as to how this is done? Any help would be appreciated I am new to asp.net

    Friday, April 10, 2009 10:29 AM
  • User1306565749 posted

    Hi,
    System.IO.FileInfo f =  new System.IO.FileInfo("c:\\YServer.txt");          
    String textFile = f.Name;
    String [] arr = textFile.Split('.');

    String FileNAme = arr[0];
    String ext = arr[1]; //please chek for the correct array index, this code has some risk, you may get array out of range/null reference exception

    OR you do it in another way

    String extension = textFile.Substring(textFile.LastIndexOf('.')+1);

    http://msdn.microsoft.com/en-us/library/system.string.split.aspx

    Please Mark This Post as Answer, if it helped

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 15, 2009 5:37 AM