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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem in renaming CSV file after hosting ASP.NET application

Problem in renaming CSV file after hosting ASP.NET application

Scheduled Pinned Locked Moved ASP.NET
asp-nethelpcsharpwindows-adminhosting
5 Posts 2 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.
  • R Offline
    R Offline
    Rashmi_Karnam
    wrote on last edited by
    #1

    Hi, I have a Fileupload control, from where i am uploading CSV file and reading data from it and displaying in a gridview. If data is incorrect i am editting in GrdiView and click on Finish button. On click of finish button i am writing updated value back to CSV file from Gridview. This functionality i have implemented, but after hosting this application in IIS, when i access it in same system its rewriting to CSV file and renaming the file also. But if i browse hosted application in some other system and if i upload a file which is on browser system, its not renaming a file and not updating it. So please can any one help me what are the permissions i need to set in IIS or to file i am access, so that i can rename and update that file. I have checked following possiblities already 1. create ASPNET account and grant full permission for read, write.... 2. In IIS gave Anonymous access to user. 3. Checked with Impersonate option in web.config file. 4. Gave permissions to CSV file like read, write .... Code ----- writing to CSV File ------------------- StreamWriter sw = new StreamWriter(localsavedFilePath) foreach (DataRow row in dtCSV.Rows) { sw.Write("\"" + row[0].ToString() + "\""); sw.Write(sw.NewLine); }sw.Close(); File.Copy(localsavedFilePath, OriginalFileUploadedPath, true); Renaming File -------------- File.Move(OriginalFileUploadedPath, OriginalFileRenamedPath);

    Rashmi.M.K

    T 1 Reply Last reply
    0
    • R Rashmi_Karnam

      Hi, I have a Fileupload control, from where i am uploading CSV file and reading data from it and displaying in a gridview. If data is incorrect i am editting in GrdiView and click on Finish button. On click of finish button i am writing updated value back to CSV file from Gridview. This functionality i have implemented, but after hosting this application in IIS, when i access it in same system its rewriting to CSV file and renaming the file also. But if i browse hosted application in some other system and if i upload a file which is on browser system, its not renaming a file and not updating it. So please can any one help me what are the permissions i need to set in IIS or to file i am access, so that i can rename and update that file. I have checked following possiblities already 1. create ASPNET account and grant full permission for read, write.... 2. In IIS gave Anonymous access to user. 3. Checked with Impersonate option in web.config file. 4. Gave permissions to CSV file like read, write .... Code ----- writing to CSV File ------------------- StreamWriter sw = new StreamWriter(localsavedFilePath) foreach (DataRow row in dtCSV.Rows) { sw.Write("\"" + row[0].ToString() + "\""); sw.Write(sw.NewLine); }sw.Close(); File.Copy(localsavedFilePath, OriginalFileUploadedPath, true); Renaming File -------------- File.Move(OriginalFileUploadedPath, OriginalFileRenamedPath);

      Rashmi.M.K

      T Offline
      T Offline
      ToddHileHoffer
      wrote on last edited by
      #2

      Check the identity that runs the application pool process. Give that account full control to the directory where you are writing the file. Also, here is a tip. Instead of using a StreamWriter, use a StringBuilder to build your .csv then use System.IO.File.WriteAllText.

      I didn't get any requirements for the signature

      R 1 Reply Last reply
      0
      • T ToddHileHoffer

        Check the identity that runs the application pool process. Give that account full control to the directory where you are writing the file. Also, here is a tip. Instead of using a StreamWriter, use a StringBuilder to build your .csv then use System.IO.File.WriteAllText.

        I didn't get any requirements for the signature

        R Offline
        R Offline
        Rashmi_Karnam
        wrote on last edited by
        #3

        Hi, Thanks for the reply... I tried what ever you have suggested, still renaming issue exist. i used string builder to build CSV file and used File.WriteAllText. It works fine only when i run application using Visual Studio and on which ever system i host the application. Except these two systems on all other system its not working. Please help me.... We need to deliver the project but due to renaming issue stuck up...

        Rashmi.M.K

        T 1 Reply Last reply
        0
        • R Rashmi_Karnam

          Hi, Thanks for the reply... I tried what ever you have suggested, still renaming issue exist. i used string builder to build CSV file and used File.WriteAllText. It works fine only when i run application using Visual Studio and on which ever system i host the application. Except these two systems on all other system its not working. Please help me.... We need to deliver the project but due to renaming issue stuck up...

          Rashmi.M.K

          T Offline
          T Offline
          ToddHileHoffer
          wrote on last edited by
          #4

          What exception are you getting?

          I didn't get any requirements for the signature

          R 1 Reply Last reply
          0
          • T ToddHileHoffer

            What exception are you getting?

            I didn't get any requirements for the signature

            R Offline
            R Offline
            Rashmi_Karnam
            wrote on last edited by
            #5

            I wont get any exception. When i click on Finish button in my screen, i am interacting with DataBase and at last saving the CSV file and changing the name of the file. It wont throw any exception as its working fine in local system using VS2008 application and also when i host the application in my system itself. But if any one browse same application on different system, all Database activities are working fine and even all the code written for renaming CSV file will get executed but it wont rename the file. :((

            Rashmi.M.K

            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