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 the code it is clearer, but it doesn't change anything, the problem seems deeper. I don't understand why it works on simple pc but not online. I just emailed the people who own the servers to find out if there are any bans or restrictions. Or even see if the path system works the same online or not...
Friendly
Sy.
 
I might have misunderstood the thrust of the problem, or missed something in the thread, but I did just want to point out that you cannot deploy code to an Internet web server that will create files on your local disk

If you write code that successfully creates a text file in C:\temp on your local machine, and you upload that code to a web server and do whatever you need to do to trigger it to run then it will only either

a) create a file in c:\temp on the web server
b) fail because of some (probably permissions) related problem
 
A permissions problem... Ok understood. I await the response of the people of the web server to know, permissions etc. it's very complicated for something that should be very easy. Thanks. I wish the best for you and your team in 2023 :0)
Friendly
Sy.
 
So you want your code to run on the web server and create files on the web server? (it's kinda bizarre; mostly we don't do that, not least because of security risks)
 
Why strange/bizarre ? We should do whatever we want when we want, computers should be used for that, even my grandmother should be able to modify her web pages easily. :0). How is this a danger? Else, I have the solution, it was a matter of path and permission. Their path is very particular and does not correspond to that in FileZila... Then for the permissions, we cannot do it from FileZila but only in their site. Thank you for your help otherwise I will be stuck again, that's great... Now I have to debug my HTML code cos it's a shame. :0) and of course the secure mode does not work... Damned ! The guy who made me the Jeanneton site is a treacherous villain and if I had the courage I would take a boat, oars to cross the Channel and I I'll beat him up in Brighton.
Happy 2023!
Friendly
Sy.
 
Ok everything is working perfectly now. In fact it was a path problem cos the Filezilla paths I was using did not match those of the Nutty server... Thanks for your help.
But I come back with my questions about writing and reading files in Csharp.


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

So this code allows me to create a file and place it where I want, perfect.



But now what would be the code to read this file with the same .IO system? Because I know how to read this file with Console.WriteLine etc etc But this way is not suitable for me for other deeper coding reasons. Can you help me again? :0)
Friendly
Sy
 
Last edited by a moderator:
You would use a StreamReader and use ReadLine() .

Console.WriteLine() is used for printing out values to the console (or standard output). It is not used for reading files. I'm wondering how you managed to use it to read a file. (I can see how you used it to show on the console what you read in.)
 
Thank you for taking the time to respond.
Precisely it is not only to display that I need, I want to use the code that would contain my target file but to use it. I want to be able to read my .csv files that I created with your help cos I plan to put usable code in this csv file, and that for many reasons, including the enormity of my AI which suddenly becomes less and less usable and many other things. Am I understandable and can you help me again ? :0)

You help me ok that's great, but how can I help you in turn?
Friendly
Sy.
Ps: I can show you how I manage to use it to read csv, txt files. It's complicated, it will take time and the code is certainly very bad but it works. I can email you to let you know if you're interested. Are you interested ?
 
I looked at the page and for me it's Martian, you don't realize that it's not only specialists who use your site... :0) I just need some line of code that's all... If you don't want it let me know.
Friendly
Sy.
 
That was the simplified version of how to parse a CSV file the right way (and not get caught by corner cases like quoted strings and comment lines).

The complicated version of that is:
 
I will take a week to find to make this code and in addition it will be bad.

C#:
<?csharp
System.IO.StreamWriter sw = new System.IO.StreamWriter(vars["Dircsv"]+ vars["name_letter"] + ".txt", true);
sw.WriteLine(vars["type_text"]);
sw.Flush();
sw.Close();
?>

I just need the read/parse/StreamReader equivalent to retrieve code from my csv. Please, it will take you 10 minutes and it will be correct, whereas for me, it will take me a month and the code will be poisonous... Thanks :0)
Friendly
Sy
 
You are using the code tags correctly. There is no need to add the <?csharp and ?> markup.

Sorry, we are not a code writing service.
 

Latest posts

Back
Top Bottom