I am getting an error message and I have not been able to figure hot
how to fix it. I have done some research with no answers yet.
I found this code that may help? Not sure what to do with it.
using (StreamWriter sw = new StreamWriter (fullAddress , false,
Encoding.UTF7))
Error message::::::::::::::::::::::::::::::::::::::::::: :::
[code]
Compilation Error
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name
'StreamWriter' could not be found (are you missing a using directive or
an assembly reference?)
Source Error:
Line 40:
Line 41:
Line 42: StreamWriter sw = new StreamWriter(arg1, arg2); //This was
commented out????
Line 43: //the line above is where I get the errors either way.
Line 44:
Source File: E:\webapps\finance\gfst\asp\jeffUploadNsave.aspx Line:
42
Code::::::::::::::::::::::::::::::
void WriteToFile(string szData, string szFilePath)
{
//Write to file
StreamWriter sw = new StreamWriter(arg1, arg2); //This was commented
out???? StreamWriter(arg1, arg2);
//the line above is where I get the errors either way.
// Constructor with 2 arguments:
// 1) Path location of file
// 2) Append or Overwrite Data
StreamWriter(@"G:\Inetpub\wwwroot\csf\Tutorials\Ex ec\fileIO.txt",true);
//This will append the given input to the file since arg2 is true
sw.Write("I love C# and I don't care who knows it!~~" + "<br>");
//Cleanup
sw.Close();
} 4 20525
StreamWriter is part of System.IO, so you need a reference to it.
Try putting
using System.IO;
at the top of your code.
HTH,
pagates
"rex64" wrote: I am getting an error message and I have not been able to figure hot how to fix it. I have done some research with no answers yet.
I found this code that may help? Not sure what to do with it. using (StreamWriter sw = new StreamWriter (fullAddress , false, Encoding.UTF7))
Error message::::::::::::::::::::::::::::::::::::::::::: ::: [code] Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'StreamWriter' could not be found (are you missing a using directive or an assembly reference?)
Source Error: Line 40: Line 41: Line 42: StreamWriter sw = new StreamWriter(arg1, arg2); //This was commented out???? Line 43: //the line above is where I get the errors either way. Line 44:
Source File: E:\webapps\finance\gfst\asp\jeffUploadNsave.aspx Line: 42 Code:::::::::::::::::::::::::::::: void WriteToFile(string szData, string szFilePath) { //Write to file StreamWriter sw = new StreamWriter(arg1, arg2); //This was commented out???? StreamWriter(arg1, arg2); //the line above is where I get the errors either way.
// Constructor with 2 arguments: // 1) Path location of file // 2) Append or Overwrite Data StreamWriter(@"G:\Inetpub\wwwroot\csf\Tutorials\Ex ec\fileIO.txt",true);
//This will append the given input to the file since arg2 is true sw.Write("I love C# and I don't care who knows it!~~" + "<br>");
//Cleanup sw.Close(); }
rex64,
The reason for this is that you are using the shorthand for the
StreamWriter class, and you don't have the appropriate imports statement at
the top. What you want to do is place this at the top of your page:
<%@ Import namespace="System.IO" %>
And it should work.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"rex64" <re****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com... I am getting an error message and I have not been able to figure hot how to fix it. I have done some research with no answers yet.
I found this code that may help? Not sure what to do with it. using (StreamWriter sw = new StreamWriter (fullAddress , false, Encoding.UTF7))
Error message::::::::::::::::::::::::::::::::::::::::::: ::: [code] Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'StreamWriter' could not be found (are you missing a using directive or an assembly reference?)
Source Error: Line 40: Line 41: Line 42: StreamWriter sw = new StreamWriter(arg1, arg2); //This was commented out???? Line 43: //the line above is where I get the errors either way. Line 44:
Source File: E:\webapps\finance\gfst\asp\jeffUploadNsave.aspx Line: 42 Code:::::::::::::::::::::::::::::: void WriteToFile(string szData, string szFilePath) { //Write to file StreamWriter sw = new StreamWriter(arg1, arg2); //This was commented out???? StreamWriter(arg1, arg2); //the line above is where I get the errors either way.
// Constructor with 2 arguments: // 1) Path location of file // 2) Append or Overwrite Data StreamWriter(@"G:\Inetpub\wwwroot\csf\Tutorials\Ex ec\fileIO.txt",true);
//This will append the given input to the file since arg2 is true sw.Write("I love C# and I don't care who knows it!~~" + "<br>");
//Cleanup sw.Close(); }
That did not work:
Compilation Error
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.
Compiler Error Message: CS1519: Invalid token 'using' in class, struct,
or interface member declaration
Source Error:
Line 6: <body bgcolor="#ffffff" style="font:8pt verdana;">
Line 7: <script language="C#" runat="server">
Line 8: using System.IO;
Line 9: //Strings: http://www.peachpit.com/articles/art...1938&seqNum=12
Line 10: //http://www.developerfusion.com/show/4398/
That worked. I put it at the very top above the C# declartation. Thanks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: |
last post by:
Hi,
When constructing StreamWriter with the following..
FileStream f = new FileStream(..);
StreamWriter s = new StreamWriter(f);
Then attempt to write out åäö letters they become garbage.
...
|
by: ShadowOfTheBeast |
last post by:
Hi, I have got a major headache understanding streamReader and streamWriter
relationship.
I know how to use the streamreader and streamwriter independently.
but how do you write out using the...
|
by: MrKrich |
last post by:
I try to use the StreamWriter to write from file reader
(my file reader is not a text file) and I got this error
message
streamWriter.Write(fileReader.ReadToEnd)
"Found a high surrogate char...
|
by: Don |
last post by:
I have a strange bug popping up every once in a while. I've got a section
of code that executes these statements when working with a streamwriter:
--- Start ---
....
' Close the...
|
by: Don |
last post by:
I'm having problems working with a streamwriter object. After closing the
streamwriter and setting it to Nothing, I try to delete the file it was
writing to, but I always get the following error...
|
by: Mads Westen |
last post by:
Hi,
I'm making some changes to my program, because I need to write with Codepage
850.
Before I used FileStream, but I found code to use with StreamWriter instead.
My problem is, that I don't...
|
by: Heron |
last post by:
Hi,
Could someone explain me why the following code doesn't work? The
memorystream always remains with length 0.
MemoryStream input = new MemoryStream();
|
by: BLUE |
last post by:
I insert a string in cache in a property set and I retrieve that string in
the get.
I retrieve my string with Read web method and I insert it with Write web
method: to try cache I do Read,...
|
by: fniles |
last post by:
I am using VB.NET 2005 and streamWriter to write to a file.
Before writing to the file, I encrypt the string.
StreamWriter does not write it correctly to the file, I have to change to
FileOpen,...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |