fileinfo

Can I show file copy progress using FileInfo.CopyTo() in .NET?

I've created a copy utility in c# (.NET 2.0 Framework) that copies files, directories and recursive sub directories etc. The program has a GUI that shows the current file being copied, the current file number (sequence), the total number of files to be copied and the percentage completed for the copy operations. There is also a progress ...

LastAccess Time is incorrect

every time i create a FileInfo object and access it's lastaccesstime property, it's always a few minutes off. the file property window remains constant, however the application shows that it is usually a few minutes after the property window time. Also, i noticed that if i drag the file to the cmd window to pass the filename as an argum...

How do I obtain File Version info from a C++ exe in C#?

I need to get the File version information from an exe file originally written in C++ from a C# program. Using Assembly.LoadFile(fullpath).GetName().Version results in a BadImageFormatException. Can anyone help? Cheers, Dan ...

Changing a Read Only attribute on a file

I can't seem to change the read only flag on a file. I've tried this on Vista and XP with the same result, so I don't think it's a UAC related issue. Nothing I've done seems to work though. See the sample below. Can someone tell me what I'm doing wrong? public bool UpdateResFile(string fileName, string language, string objectName, stri...

Accessing MP3 Player / USB Storage device

Hi I'm trying to access a USB Storage device, however the device although appearing in the commputer / Drives section, is not allocated a Drive letter, thus when I itterate through the attached drives link text it does not appear, I've taken the "Location" from a file on the drive (properties) and it comes up as COMPUTER/Q1/Datacasts bu...

When passing a file name to a method, should I use FileInfo or a plain file name?

Well, the title says it all. When passing a file name to a method, should I use a FileInfo object or a plain file name (string)? Why would I prefer one to the other? Some of my colleagues like to write method like this: void Export(FileInfo fileInfo) Is it better than: void Export(string fileName) Thanks! ...

FileInfo compact framework 3.5 - cannot find file

Hello, I am using the FileInfo class. However, the file info cannot find the file. The file is called log4Net.config and I have added it to my project. I have set the properties to build action = 'Content' and copy output = 'copy always' When I run the following code: FileInfo logfileInfo = new FileInfo("Log4Net.config"); if (!log...

Why are we getting “The path is not of a legal form” for a FileInfo constructor?

We're creating a FileInfo object in C# using the following code: if (planConfig->OrganisationsFilePath != nullptr) { FileInfo^ file = gcnew FileInfo(planConfig->OrganisationsFilePath); //Do some stuff here } and our customers are reporting that they see an ArgumentException with “The path is not of a legal form” as the message b...

Fileinfo Milisecond of last access isn't update

In the method monitorCallback() I write a the time to text file. after writing the file I check the FileInfo of file and print it. I have got the following result: time = 16/08/2009 14:01:46, mili = 307 time = 16/08/2009 14:01:51, mili = 291 time = 16/08/2009 14:01:56, mili = 291 time = 16/08/2009 14:02:01, mili = 291 time = 16/08/20...

Can certain File.IO objects in .NET (like DirectoryInfo) keep a removable device referenced even after programm termination

I have written a program in .NET that recurses through all files of a source and destination directory and its subdirectories, compares lastwritetime and copies/deletes files to/from the destination directory based upon comparison result. When eg. the destination directory is a directory on a removable drive (usb), I can not remove the ...

File paths with non-ascii characters and FileInfo in C#

I get a string that more or less looks like this: "C:\\bláh\\bleh" I make a FileInfo with it, but when I check for its existence it returns false: var file = new FileInfo(path); file.Exists; If I manually rename the path to "C:\\blah\\bleh" at debug time and ensure that blah exists with a bleh inside it, then file.Exists starts...

C#: Retrieve Names of Installed Screen Savers

I want to be able to show basically the same list that the Windows Screen Saver dialog shows, with the name of each screen saver. The problem I've run into however is that the names that show up in the drop down list on the dialog don't seem to correspond to the filename, embedded file information, anything in the registry, etc. For ex...

Why is FileInfo showing an extra file extension?

I have been having problems with creating a download list of files for a downloader and was getting unexplained "File Does Not Exist" returns. My .avi files were returning found but but .exe and .txt files were getting the not exists. I have now found by pulling in the whole directory and examining the file contents that my .exe files ...

DirectoryInfo, FileInfo and very long path

I try to work with DirectoryInfo, FileInfo with very long path. I try use \\?\c:\long path (i got illegal caracter with fileInfo and DirectoryInfo) I try use file://c:/long path (i got uri not supported) Can i use ~ in a path or something else. I read this post but i would like to use another way that call a API. Is it any other sol...

ASP.NET MVC getting last modified date/FileInfo of View

I'm required to include the last modified date on every page of my applications at work. I used to do this by including a reference to <%= LastModified %> at the bottom of my WebForms master page which would return the last modified date of the current .aspx page. My code would even check the associated .aspx.cs file, compare the last mo...

Using Python, how do I get an array of file info objects, based on a search of a file system?

Currently I have a bash script which runs the find command, like so: find /storage/disk-1/Media/Video/TV -name *.avi -mtime -7 This gets a list of TV shows that were added to my system in the last 7 days. I then go on to create some symbolic links so I can get to my newest TV shows. I'm looking to re-code this in Python, but I have a...

How to set File Info from a script in Photoshop CS4

Hi, I am developing a Photoshop CS4 script and want to set some of the File Info properties on the open document from within the script. In other words, I want to do the equivalent of choosing File -> File Info and editing some properties, only via the scripting language (Javascript). Thank you. ...

Pass StreamReader to WCF service from Silverlight's Async Call

Hi, I want to import records from csv file to the DB from Silverlight front end. I am using WCF service to perform the DB operations. When I pass the entire file path (hard coded), I am able to add records to the DB, but as OpenFileDialog in Silverlight doesn't allow to obtain the file path's (due to security reasons), I tried using WCF...

How do I compare one collection of files to another in c#?

I am just learning C# (have been fiddling with it for about 2 days now) and I've decided that, for leaning purposes, I will rebuild an old app I made in VB6 for syncing files (generally across a network). When I wrote the code in VB 6, it worked approximately like this: Create a Scripting.FileSystemObject Create directory objects for ...

(C#) FileInfo array out-of-bounds exception ... except it is not.

Code: DirectoryInfo[] d2 = new DirectoryInfo[400]; d2 = moreDirect.GetDirectories(); //Declaring FileInfo array FileInfo[] f = new FileInfo[300]; f = d2[z].GetFiles(); if (d2[z].Exists) { if (f[y] != null) { ... //FileInfo does it stuff and somewhere it does ++y depending on the situation blahblahblah if (...