Link to home
Create AccountLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

ASP.NET / VB: Write String to File

Using ASP.NET / VB, I want to write a string to a file.

This does NOT work:
<%@ Page Language="VB" AutoEventWireup="false" %>
<%

Dim xyz as String = "Hello World"
writeStream = New FileStream("output.txt", FileMode.Create)
Dim writeBinay As New BinaryWriter(writeStream)
writeBinay.Write(xyz)
writeBinay.Close()

%>

Open in new window

Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

>writeStream = New FileStream("output.txt", FileMode.Create)

First give it a full path

writeStream = New FileStream(Server.MapPath("output.txt"), FileMode.Create)

and next make sure that user under which your app pool is running has write access to the folder.
Avatar of hankknight

ASKER

Thanks.  I did this but I still get an error:
Compiler Error Message: BC30451: 'writeStream' is not declared. It may be inaccessible due to its protection level.


<%@ Page Language="VB" AutoEventWireup="false" %>
<%

Dim xyz as String = "Hello World"

writeStream = New FileStream(Server.MapPath("output.txt"), FileMode.Create)
Dim writeBinay As New BinaryWriter(writeStream)
writeBinay.Write(xyz)
writeBinay.Close()

%>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account