fileinfo

is it possible to create an in-memory file and access it with FileInfo?

I want to FTP a file, and I am using the FileInfo class for certain things. Would it be possible to create an in-memory file and initialize FileInfo with it? How could I then write the file to disk if I wanted to afterwards? ...

How can i get all the files that DO NOT start with "Something"?

The line below fetches all files that start with Cake. Dim fi As System.IO.FileInfo() = di.GetFiles("Cake*") How can i write the search pattern to get all the files, that do not start with Cake? ...

Convert XmlDocument to FileInfo

I have a web service which returns a string representing an Xml file. The string is properly formed xml. I need to create FileInfo object from the string so that I can deserialize it. I don't have the file path or even if i do thats of no use as it is a disconnected server. I can convert string to XmlDocument by - XmlDocument doc = n...

C# Problem with fileinfo delete command

My application does this, play the selected sound using wmplib and upon statechangeevent = 1 (media player stopped), i will close the player using the close() command and setting the URL to ""; Now every time, i tried to delete a sound that is currently playing, in actual fact, it will be deleted, because when I looked at the directory,...

How can I determine when a file was most recently renamed?

I have a program that compares files in two folders. I want to detect if a file has been renamed, determine the newest file (most recently renamed), and update the name on the old file to match. To accomplish this, I would check to see if the newest file is bit by bit identical to the old one, and if it is, simply rename the old file t...

fileinfo and mime types I've never heard of

I'm not a stranger to mime types but this is strange. Normally, a text file would have been considered to be of text/plain mime but now, after implementing fileinfo, this type of file is now considered to be "text/x-pascal". I'm a little concerned because I need to be sure that I get the correct mime types set before allowing users to up...

How to create a new file from a FileStream?

I have a javascript file as an embedded resource in an assembly, and I'm trying to use the Stream from "System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("someName");" to create a new FileInfo object. My confusion is how to use a stream to create the FileInfo. If anyone can help me in this I would be greatly app...

Understanding a boolean on DirectoryInfo.Exists

Hi everyone, var fileOpen = new OpenFileDialog(); var clickedOk = fileOpen.ShowDialog(); if (!((bool) clickedOk)) return; var path = fileOpen.FileName; var diPath = new DirectoryInfo(path); var fiPath = new FileInfo(path); Debug.WriteLine(diPath.Exists); I am just wondering why diPath.Exists is false in this case? Since the user has...

ContentLength vs Actual File.Length

Does anyone has any experience wherein the requested file to download (HTTP) content length in the header does not equal to the actual file length (size) when downloaded? ...

Blank space after file extension -> weird FileInfo behaviour

Somehow a file has appeared in one of my directories, and it has space at the end of its extension - its name is "test.txt ". The weird thing is that Directory.GetFiles() returns me the path of this file, but I'm unable to retrieve file information with FileInfo class. The error manifests here: DirectoryInfo di = new DirectoryInfo("c...

How is FileInfo Serialized?

I want to save file metadata (mostly path/name) along with the contents of the file. I noticed that FileInfo is serializable. Does anyone know data is serialized when you save a FileInfo object? I would assume that only metadata is saved, not the contents of the file? ...

File details from a string in C#

Hello, I have a string in C# String file="\\mserver-80\docs\somedoc.doc" Now How do I get fileInfo from the above sting. What I mean is, I want to declare something like FileInfo fInfo = new FileInfo(file); fileExtn = fInfo.Extension; ...

Drag drop a file on top of .exe file to get fileinfo

Hey, As the title say. I know how to do this in C# only, but when trying to do this with WPF I can't find out where or what to add to read the filename when the program starts. public static void Main(string[] args) { if (Path.GetExtension(args[0]) == ".avi" || Path.GetExtension(args[0]) == ".mkv") { string pathOfFile =...

GetFiles with multiple extentions

How do you filter on more than one extension? I've tried: FileInfo[] Files = dinfo.GetFiles("*.jpg;*.tiff;*.bmp"); FileInfo[] Files = dinfo.GetFiles("*.jpg,*.tiff,*.bmp"); ...

FileInfo lock files!

Hi all. Imagine a winform app, who copy updated assemblies from a source folder A to a destination folder B. I use simple DirectoryInfo.GetFiles methods to fill a listview, comparing version of assembly in folder A and B; if some assemblies are newer, I start my update method. In this method, before copying, I try if all file in B folde...

Application Settings + DirectoryInfo/FileInfo

I'm still new to C#... I'm building a WPF application and I'm trying to apply some User Application Settings. It's easy to insert standard App Settings (int, double, string, etc). I've even got something like WindowState inserted. I'd like to have a DirectoryInfo and/or FileInfo as savable settings instead of Strings. Selected type:...

Attaching arbitrary data to DirectoryInfo/FileInfo?

I have a site which is akin to SVN, but without the version control.. Users can upload and download to Projects, where each Project has a directory (with subdirs and files) on the server. What i'd like to do is attach further information to files, like who uploaded it, how many times its been downloaded, and so on. Is there a way to do t...

How do I list imags from directory?

I'm trying to show all images within a specified directory. The following code lists all allowed file names: function getDirectoryList() { // create an array to hold directory list $results = array(); // create a handler for the directory $handler = opendir($this->currentDIR); // open directory and walk thro...

What is the fastest way of getting a file length in .net?

What is the fastest way of getting a file length in .net? Note: I am accessing files via a network share. So far I have 1.5ms FileInfo.Length .5ms FileStream().Length ...

Combine two (or more) FileInfo's...

I have something similar to this: var d1 = new DirectoryInfo(Path.Combine(source, @"bills_save." + dt)); var d2 = new DirectoryInfo(Path.Combine(source, @"reports_save." + dt)); var f1 = d1.GetFiles(); var f2 = d2.GetFiles(); I want to get, and combine, all the filenames into one FileInfo list. Would make my parsing a lot easier. C...