Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating a file in asp.net with vb.net

Status
Not open for further replies.

Shift838

IS-IT--Management
Jan 27, 2003
987
US
I have a webform with various check boxes on them and a submit button. I want to be able to create an html file (text file) on the fly depending on what is checked. How can this be done? Also I want to use a message box on the form if an error occurs how can a message box be displayed in vb.net from a webform?
 
To create a file:

System.IO.File.Create(path)
(for setting the path look in Server.MapPath(...))

BUT you must set permission to WRITE at this folder, because it is a web app; not a windows app!



The message:

msgbox(...)

Probably there will be an error on showing the modal dialog


-bclt
 
I have tried both and get errors through visual studio and it will not compile.. I have tried:

System.IO.File.Create("c:\temp\test.txt")

and get compile errors.. I'm using Visual Studio .NET 2003.
 
You want to create a file through VB or ASP ?
 
I am programming a website with Visual Studio and using VB.net with ASP.net as a web form. I'm using ASP.net Web application in Visual Studio and want to use VB.net as the back end code. I do not want to put it on the webform itself but use the behind code page to do it.
 
Your web app is in "c:\inetpub\ The local server is "c:\inetpub\ so the application is in "
You cannot access "c:\..." because it is a client's folder (have no permission) and though you do not even know if the logic drive exists (I mean "c:\").

You may access (to read, write, read/write etc) the folders and file in "/webapplication1". Try to create a folder in "/webapplication1/MyFolder". Then right click -> properties -> security tab and make sure that permissions for: read, write and read/write are checked as "Allowed".Then:

System.IO.File.Create(Server.MapPath("MyFolder") + "the file.txt")



Hope now...
-bclt
 
You cannot access "c:\..." because it is a client's folder (have no permission) and though you do not even know if the logic drive exists (I mean "c:\").
bclt, That is 100% incorrect! By using the line:
Code:
System.IO.File.Create("c:\temp\test.txt")
that will attempt to create a file on the server not the client. Simply by changing it to:
Code:
System.IO.File.Create(Server.MapPath("MyFolder") + "the file.txt")
would write it correctly but that can also be done using an absolute path like the first example.

The correct reason that the error is occuring is the permissions of the ASPNET account (which you described how to change above).

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Right !

As for the second: "will attempt to create a file on the server not the client" that's what i meant, and duo to this mentioned how to set permissions.
 
I was able to get it working by:

FileOpen(1, "c:\temp\test.log", OpenMode.Output)
Print(1, "just a test")
FileClose(1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top