Last post Jul 18, 2017 03:32 PM by Billy Liu
Jul 12, 2017 03:33 PM|aspfun|LINK
I used code below to export datatable to text file and saved it to c:\mytest.txt but got an error said
Access to the path 'C:\mytest.txt' is denied
How to fix it?
Dim i As Integer = 0
Dim sw As StreamWriter = Nothing
sw = New StreamWriter("c:\mytest.txt", False)
For i = 0 To submittedDataTable.Columns.Count - 2
sw.Write(submittedDataTable.Columns(i).ColumnName + ";")
For Each row As DataRow In submittedDataTable.Rows
Dim array As Object() = row.ItemArray
For i = 0 To array.Length - 2
sw.Write(array(i).ToString() + ";")
Jul 12, 2017 03:47 PM|ryanbesko|LINK
You won't be able to write to the root of the C drive. Make a folder to put it in, i.e. C:\NewFolder\filename.txt and make sure the folder has permissions that allow access. Give full permission to everyone until you figure out what credentials you are
running as in development. Also, once this is hosted on a web server, the application pool identity will need to have write access to the necessary folder.
Jul 12, 2017 07:04 PM|aspfun|LINK
Thank you. Once creating a folder in C, the file was saved.
Jul 13, 2017 03:49 PM|aspfun|LINK
Once moving app to web server, the file was saved to server C drive.
How to save it into user's C drive?
Jul 18, 2017 03:32 PM|Billy Liu|LINK
Sorry, you couldn't save file to user's C drive.
But you could let user download your file.