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:
Thanks for trying to put your code in code tags. For this forum, it uses BBCodes, rather than the XML style code tages, so you'll need to use [code] ... [/code]. Alternatively, just use the toolbar button that looks like </>.
 
It works perfectly on my pc but not online...
You'll have to help us out... where are you trying to run this online? What's the URL of the site?

What error are you getting when you try to run your code in that site? Are you sure that you are allowed to write files into the path that you are building up?
 
Wow, thanks for responding so quickly... Moon IA's URL is Jeanneton.com. There is no error message. Nothing happens, that's all. And I can't find anywhere the file that I manage to create very well on my pc. I just copy paste the code. The rest of the csharp code works but not this one. Thanks.
 
Sorry. Thae page just seems to be giving me a perpetual loading GIF and I cannot type anything into the textbox. Furthermore, my 2 semesters of college French that I took over 25 years ago and never exercised since cannot translate enough on that page. Google Translate got me a lot further, but I still don't see where C# code would be uploaded and integrated into the system.

Is there a link for the source code that you downloaded and are running on your local machine?
 
It's true that the site is taking a long time to load this evening, it took me 25 seconds for it to start... No, the person who adapted the AI software from pc to internet keeps the code jealously, he is a paranoid and a miser who made me pay a high price for the slightest comma of the code he was laying. In short, he ripped me off because I trusted him. He always refused to give me anything. I think he was a crook who boasted of knowledge he didn't have.
Well, the code I sent you is sent from the software response. For example, in the Jeanneton. I type an entry
"Make me an AAAA file and put BBBB in it"
And the code I gave you sends in response what I ask it where I want and it works on a simple PC not online. I hope to be clear. I don't think it's a path problem because I've tried several and nothing.
Thanks for taking the time to look.
Friendly.
Sy
 
I try different type/kind of code an i receive this error response:

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

??????
 
Please put code in in code tags: Press the button on the toolbar that looks like </>, and then put the code in the body of the form that pops up. As you can see in your post #7, which I tried to fix up with code tags, it was too late. The forums software thought that everything you typed into the square brackets after vars was some kind of BBCode command, and so it swallowed it. As it stands now, your code in post #7 is very similar to your code in post #1, except for the missing indexers into vars.

It looks like your error message didn't get posted. What error did you get?

I waited for about 3 minutes, but all I got was the spinning wheel and unable to type into the textbox.
 
Ah. It didn't like me using an ad blocker. Turning off my ad blocker, managed to get in in about 1 minute. It doesn't look like it even takes C# code:
1672712387109.png


So how exactly are you getting it to run your C# code online?
 
What !? I'm talking with Jeanneton... Why would it work for me and not for you?... Any idea? It's true that the AI is huge but I never waited more than 25 seconds when there were a lot of people. It is also true that the guy who made the adaptation made me a filthy job but it still worked but only in unsecured mode. Use http:// not https://
 
Again thanks to take time... The inputs only take natural language and not directly code. There is an text editor where I enter the inputs it's usually questions

Input: Who is King Arthur?
And in
Output: I know him he lives in Camelot.

The app calls this a Rule.

In our case it is written the code that I gave you in output. Lots of other csharp codes work but not this one online. The only difference is that it doesn't work online as some kind of incompatibility
 
This won't solve your problem with your online AI, but it will make the code from post #1 much more readable:
C#:
var dirCsv = vars["Dircsv"];
var nameLetter = vars["name_letter"];
var typeText = vars["type_text"];
var filename = $"{dirCsv}{nameLetter}.csv";
var contents = $"Name,Infos,{nameLetter},{typeText}";
using (var sw = new System.IO.StreamWriter(filename, true))
{
    sw.WriteLine(contents);
}

Lines 1-3 pull the values out of your dictionary of variables vars.
Line 4 builds up the filename like you previously did but using a more legible form to see how the component values fit together.
Line 5 similarly builds up the contents that will be written into the stream.
By having all of these is separate variables, it will be much easier to debug to see what values are getting passed around. Don't worry about it looking inefficient, because the C# optimizer is actually very good about removing these extra steps when you build a Retail build instead of Debug build.

With the using statement, the sw will be automatically disposed. The StreamWriter's IDisposable implementation will automatically flush and close the stream writer.

Anwyay, with all that, that will only just make things look better code wise for your local machine. It won't fix anything for your online case because functionally, its still the same and what you have locally doesn't work online.

But this will help highlight something. You can now look at the value of filename. Let's say you ended up with something like "G:\data\myAI\fun.csv". If the web server hosting that AI doesn't have a "G:\data\myAI" that the stream writer will fail to create a "fun.csv". And even if the web server did have a "G:\data\myAI" directory, most diligent programmers will be running their web apps with the least privileges necessary. So the AI will likely not have read or write permissions into "G:\data\myAI".
 
Last edited:
The app calls this a Rule.

In our case it is written the code that I gave you in output. Lots of other csharp codes work but not this one online. The only difference is that it doesn't work online as some kind of incompatibility
How do you upload these rules to the web server?
 
Well, I give up for now. Thank you for your help. But I'm amazed that it's taking you so long to load the page...it's incomprehensible.
 

Latest posts

Back
Top Bottom