Relative Content

Tag Archive for c#file

C# first move a file to another location, and then create a file with the same name in the original location again. creation time not right

//Move the file to another location File.Move(@”D:Test.log”, @”D:LogHistory” + DateTime.Now.ToString(“yyyyMMddHHmmssfff”) + “.log”); //Create the file with the same name again in the original location,the time the file was created is not the time the code was executed. StreamWriter _writer = new StreamWriter(@”D:Test.log”, true); _writer.Close(); As shown above, I want to move a log file to […]

Reading a file using a variable to store file name

I want the user to be able to input a file name and display the information within the file. I’ve used the ifstream to read the variable but it only returns an error. I implemented the error so that I could know when the program has found the file or not. I don’t know if the variable needs to be wihtin the folder of the program. Tbh i dont know how to modify it for it to work.

find if array is in a file

I need to know if all the characters in the exampleFile array are in a file in sequence.
I tried to solve it but I can’t find the problem and it still doesn’t work.
What’s the problem here?