Jason

Jason

  • NA
  • 3
  • 0

PLEASE HELP - File Permissions (Logon failure: unknown user name or bad password.)

Nov 27 2007 3:28 PM

Hello. I have a gridview that displays the file name, number of bytes and created date of a list of files in a given directory on a remote server. I use a web service to return the data and bind to the grid. If the file has been written to in the past 10 days I want to display a "new" image (indicating that the file is a new file). I'm trying to use the LastWriteDate property of the FileInfo class in the RowDataBound event to check to see if I want to display the image (please see code below) but I'm getting a file permissions error (Logon failure: unknown user name or bad password.) Does anyone know how I can pass credentials in my code?

Thanks a bunch!

                //check to see if file is new
                double numDays = System.Double.Parse(this._newPeriod);
                string tempFilePath = this._linkedFolder + @"\" + strFileName;
                FileInfo objNewFileInfo = new System.IO.FileInfo(tempFilePath);

                if (objNewFileInfo.LastWriteTime.AddDays(numDays) > DateTime.Now) //ERROR OCCURS HERE
                {
                    e.Row.Cells[2].Text = e.Row.Cells[2].Text + " <img src='../_layouts/images/custom_images/new.gif'>";