Have you tried using StreamWriter and the other system classes you are looking for? You might just need to use the full path System.IO.xxx… I tried this example in a c# component and it worked just fine:
// Create a string array with the lines of text
string[] lines = { "First line", "Second line", "Third line" };
// Set a variable to the My Documents path.
string mydocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
// Write the string array to a new file named "WriteLines.txt".
using (StreamWriter outputFile = new StreamWriter(mydocpath + @"\WriteLines.txt")) {
foreach (string line in lines)
outputFile.WriteLine(line);
}
In the referenced assembly dialog, just delete the assembly you no longer want referenced.[quote=“hjandersen, post:1, topic:42317”]
There is clearly something I need to read up on, but where do I find info on the procedure of adding and removing reference assemblies in grasshopper?
[/quote]
Yeah the interface is pretty clunky and unpleasant. It does however allow you to add and remove any assembly you want, so the base-minimum functionality is there.
Note that not all types that share a namespace in .NET are also defined in the same dll. Sometimes you need to load a different dll to get access to a type in a namespace you’ve already got.
But like Giulio said, at some point the added pain of managing assemblies just doesn’t make it worth it and switching to Visual Studio is the most sensible thing to do.
The c# editor is based on QWhale. It might not be doing autocomplete as you would expect. As I mentioned, the example above worked fine, but I just pasted it into the c# component without going through the hassle of typing. The QWhale editor might not autocomplete on that namespace for several reasons.
You are right. You code is working. I guess I got so annoyed that I began to trust the intellisense. As you all suggested I did write the code in vs instead. Working fine. As c# script I cannot get it to work (code belove is a reconstruct. The old code is long gone):
private void RunScript(ref object st)
{
System.Net.Sockets.TcpClient client = new TcpClient("10.0.0.3", 50000);
System.Net.Sockets.NetworkStream nwStream = client.GetStream();
System.Byte[] bytesToSend = System.Text.ASCIIEncoding.ASCII.GetBytes("echo");
System.Byte[] bytesToRead = null;
int bytesRead = 0;
//---send the text---
nwStream.Write(bytesToSend, 0, bytesToSend.Length);
//---read received text---
bytesToRead = new System.Byte[client.ReceiveBufferSize];
bytesRead = nwStream.Read(bytesToRead, 0, client.ReceiveBufferSize);
client.Close();
st = System.Text.Encoding.ASCII.GetString(bytesToRead, 0, bytesRead);