Question Help needed for my AI

husky44

Member
Joined
Jan 2, 2023
Messages
20
Programming Experience
Beginner
Hello :0) I have a little artificial intelligence in C# and I have a code to create a file in a directory and place some text in it. It works on my AI in my pc but not online on that same AI's site... The code is below:


C#:
   System.IO.StreamWriter sw = new System.IO.StreamWriter(vars["Dircsv"]+ vars["name_letter"] + ".csv", true);
sw.WriteLine("Name,"+"Infos "+","+vars["name_letter"]+", "+vars["type_text"]);
sw.Flush();
sw.Close();

where:
* vars["Dircsv"] is the path where I want to put the file
* vars["name_letter"] is the file name
* var["type_text"] is the text I want to put in my file.

It works perfectly on my pc but not online... Can you help me? I made this AI to make my daughter laugh and try to interest her in the IT profession. Personally I'm a clown in programming lol and I need help.
Friendly
Sy
 
Last edited by a moderator:
Here is the code i needed:

C#:
System.IO.FileStream fs = new
System.IO.FileStream("D:\\Path\\MyFile.csv",
System.IO.FileMode.OpenOrCreate,
System.IO.FileAccess.Read,
System.IO.FileShare.ReadWrite);
System.IO.StreamReader sr = new
System.IO.StreamReader(fs,
System.Text.Encoding.ASCII);
String line;
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
}
sr.Close();
fs.Close();

You wrote
/*
Sorry, we are not a code writing service.
*/
You see I didn't make any drama to give out this little code. The Internet is a sharing zone. Shame on you.
 
There are sites dedicated to doing other people's homework and projects for them. The goal of this site is to help people learn. So instead of just spoon-feeding people who just say "gimme the codez", we want to see people put in the effort of trying first, and highlight the issue that they are running into with the code they have put together.

Alas, that code you have there does not read a CSV file, and it is back to using Console.WriteLine() that you said you didn't want to use for your server side code. You see pretty happy with it though, so that must be the behavior you really want, and not the behavior that your originally described in the previous post.
 
Last edited:
Oops. Thanks a lot. :0)
This kind of code doesn't work with Verbot AI engine. It mus be inside:
C#:
<?csharp //at start
and
?> //to end

Like:
<?csharp
Console.WriteLine(File.ReadAllText("D:\\Path\\MyFile.csv")
?>

Like in the fisrt example of the thread. Of course it doesn't work like that, it miss something, i don't know what... I don't know why ? It's like "cotes" in HTML... It's an old engine but very very easy to use for a donkey like me. If you have any ideas. That will be welcome cos it's small and my AI is already huge... Very very huge... It will become unusable and sad.
Friendly
Sy.
Yes very huge . :0)
 
I know i saw that but two or one ) it's the same thing. There is definitely some code before and after but I couldn't find.
 

Latest posts

Back
Top Bottom