locked
attibutes of files are lost when fileupload control is used RRS feed

  • Question

  • User-1246495514 posted

    Hi all

    i am trying to retrieve media file duration brfore uploading to the server.

    to upload the file m using fileupload control.

     m using class file for this.

    aspx file code is ashown below

     

     

    MP3Header mp3hdr = new MP3Header();bool boolIsMP3 = mp3hdr.ReadMP3Information(Filename);

    {

     

    if (boolIsMP3)

    {

    Response.Write("Filename:");

    Response.Write(strFileName);

    }

    }

     

    and class file is as shwon below

     

    public bool ReadMP3Information(string FileName)

    {

    FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read);

    // Set the filename not including the path information

    strFileName = @fs.Name;

    char[] chrSeparators = new char[] { '\\', '/' };

    string[] strSeparator = strFileName.Split(chrSeparators);

    int intUpper = strSeparator.GetUpperBound(0);

    strFileName = strSeparator[intUpper];

    // Replace ' with '' for the SQL INSERT statement

    strFileName = strFileName.Replace("'", "''");

    // Set the file size

    lngFileSize = fs.Length;

    byte[] bytHeader = new byte[4];

    byte[] bytVBitRate = new byte[12];

    int intPos = 0;

    ......

    ....

    }

     it is displaying the error "file not found".

    if i use the same code in the aspx page itself,its working fine.

     

    if any one knows the slution please let know how to use this class file and what parameter need to pass.

     

     

    Monday, March 31, 2008 11:57 AM

Answers

  • User-1136466523 posted

    Hi

    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>

    From your description, it seems that you can get the file when you assign your code in the aspx code behind page, right?

    <o:p> </o:p>

    If so, I think the problem is caused by the path issue. If you are using relative path, please try to check if the aspx page and the cs file are in the same directory, if not, you should try to change the relative path according to the directory which contains cs file.

    <o:p> </o:p>

    Also, you can add a breakpoint in your application, and run it step by step, in this way , you can track what the file path you send to the cs file.

    <o:p> </o:p>

    Thanks.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 2, 2008 10:08 PM

All replies

  • User-1246495514 posted

    getting my question or not??

    Wednesday, April 2, 2008 1:52 AM
  • User-1136466523 posted

    Hi

    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>

    From your description, it seems that you can get the file when you assign your code in the aspx code behind page, right?

    <o:p> </o:p>

    If so, I think the problem is caused by the path issue. If you are using relative path, please try to check if the aspx page and the cs file are in the same directory, if not, you should try to change the relative path according to the directory which contains cs file.

    <o:p> </o:p>

    Also, you can add a breakpoint in your application, and run it step by step, in this way , you can track what the file path you send to the cs file.

    <o:p> </o:p>

    Thanks.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 2, 2008 10:08 PM
  • User-1246495514 posted

    yes you are right.

    thanks a lot :)

    Thursday, April 3, 2008 2:41 AM