I have a SQL Server table with a list of files (path + filename), and a folder with multiple layers and files in each layer. I'm looking for a way to reconcile the two without having to process the list twice. Currently, I'm doing this:
For Each f as FileInfo In FileListFromDatabase
If f.Exists is False, mark it as deleted in the dat...
What is the difference between File.ReadAllLines() and File.ReadAllText()?
Thank you very much.
...
We have a fairly simple program that's used for creating backups. I'm attempting to parallelize it but am getting an OutOfMemoryException within an AggregateException. Some of the source folders are quite large, and the program doesn't crash for about 40 minutes after it starts. I don't know where to start looking so the below code is...
Hi,
I am trying to run GetFiles() and it is returning 0 files on NetWare/NSS file system. The file is definitely there. Is there some other code I can run on this file system. The same code runs fine if it is run on a Windows Server.
string[] s = System.IO.Directory.GetFiles(Environment.CurrentDirectory, "file.txt");
bool exists= s.Len...
Is there a built in .NET function to get a unique filename if a filename already exists? So if I try and save MyDoc.doc and it already exists, the file will save with name MyDoc(1).doc, the same way a browser download works for example.
If not, what is the most efficient way to achieve this result?
I am using the File.Move function at ...
If I have a string, I know I can use If System.IO.File.Exists(mystring) or System.IO.Directory.Exists(mystring) to see which it is. Is there a method I can use to make a single call to determine which type it is? Since, at least in Windows, you can't have both a file and a directory with the same name, it seems like there should be a fun...
Hi,
can someone confirm that microsoft changed path length related behaviour of some classe from System.IO in .NET 4.0? For example the code below runs fine on .NET 3.5 but on 4.0 throws a PathTooLongException for me.
const string prefix = "C:\\";
const string suffix = ".txt";
var sb = new StringBuilder();
sb.Append(prefix);
for (var ...
Hello Everyone,
How do you get around the exponential conversion that takes place when inserting a value into a csv file. I have a process that creates a csv file and then starts entering rows into it. One of those fields inside a row inserts a value similar to this:
123,45,45,466,6656,23423,2455,234,2454
These are just a string of i...
I'm developing an application which checks for changes made to a file by a separate program (not written by me).
If a change is detected, it opens the file, reads the last line, then closes the file.
I'm using the following code to make sure my program doesn't try to lock the file, but only opens it in read mode:
FileStream fs =
n...
I know that in the same directory where my code is being executed some files are located. I need to find them and pass to another method:
MyLib.dll
Target1.dll
Target2.dll
Foo(new[] { "..\\..\\Target1.dll", "..\\..\\Target2.dll" });
So I call System.IO.Directory.GetFiles(path, "*.dll"). But now I need to get know the path:
string pa...
I created a sample Silverlight Web project
and I am getting 'Access is denied' when I do this:
string fileName = "map.gif";
FileInfo fileInfo = new FileInfo(fileName);
How can I give the web project access to this folder/file?
I added the image into my project, really drawing a blank here....
...
i am writing a method which sends a particular packet and gets an answer back from an electronic device. I am using system.io.ports with rtsEnabled = true.
The problem is that when entering the application the received packet is altered. I am monitoring what is being received using eltima and the packet received by eltima and that by...
Hi My Dear Friends :
How can i Make A Text File In Memory(Ram -> Save NoWhere) And Write Something On It And Open NotePad on top of Client browser And Open That Text File In It And Let the user save it by him/her self? -> in code behind
thanks in future advance
best regards
...
UPDATED
I used below solutions (loading Image from stream), but get new problem. img object is absolutely correct Image class instance with all field filled with correct values. But calling
img.Save("path/to/new/image.bmp");
on it results in new exception for GDI+ (System.Runtime.InteropServices.ExternalException, in GDI+ interface) ...
Group,
I'm looking for new and fun ways to write an array of strings to a .txt file.
-This file will be rewritten every time its called and saved.
-The file name will be dynamic enough that the .exe will know what string goes where.
For example:
~/someFile.exe "fileName" "string|string|string|"
-In this example someFile.exe is ca...
Dumb question.. is this c# code intended to read local client files?
System.IO.FileStream content = System.IO.File.Open("c:\test.txt", System.IO.FileMode.Open);
It gives me error FILE NOT FOUND
I'm running Windows 7 and IE 8.
...
I have a couple applications running in separate processes that each write to a central xml doc on the harddrive. I am using a named mutex to synchronize access to the file - but get the following exception often:
System.IO.IOException: The requested operation cannot be performed on a file with a user-mapped section open.
I realized ...
Hi, im creating temporary files to be stored in the Temp folder found by:
string path = System.IO.Path.GetTempPath()
method returns C:\windows\Temp\
i append my filename:
string filename = myfile.txt
System.IO.Path.Combine(path,filename)
However, this gives me a
"Message":"The given path\u0027s format is not supported.","StackTrac...
Hi there, I am building a class library for modbus and serial connections, I need to return an array of bytes back but when using the DataReceived event from System.IO.Ports I cannot return any since it's type is void. Also I am noticing that the DataReceived is not firing. The following is my code:
public void ConnectSerialModB...
Our application requires a user to select a photograph from their camera. The cameras I tested with while adding this feature would all appear as a drive letter in "My Computer" so loading and working with the image was a no-brainer. A coworker gave me his camera which rather than mount as a drive it triggers the awful "Scanner and Cam...