Questions tagged [fileinfo]

fileinfo refers to the properties of a file that are not part of the content, but rather meta-information such as file type, last modification time, id in the file system, etc. Use this tag for questions about reading / modifying the fileinfo in programmatic ways.

Fileinfo refers to the properties of a file that are not part of the content, but rather meta-information such as file type, last modification time, id in the file system, etc. It can include custom properties such as ID3 tags for audio files.

The list of attributes may vary depending on the file system.

Use this tag for questions about reading / modifying the fileinfo in programmatic ways.

361 questions
4
votes
1 answer

Should I handle exceptions in factory pattern class or let them propagate upwards?

I am C# developer and I'd like to use factory pattern to create objects that represent file or directory on hard disk. FileInfo and DirectoryInfo are classes in .NET used for that purpose but instead of them I'd like to have my own IFileInfo and…
matori82
  • 3,669
  • 9
  • 42
  • 64
4
votes
2 answers

FileInfo.OpenText() Fails To Read Special Characters E.G. üò°

Have some text files that display many characters as � in TextBox and TextBlock. How can I properly read and display these files in .NET WPF? File read where fi is a FileInfo. fileText = fi.OpenText().ReadToEnd(); In WPF I get the � character for ü…
paparazzo
  • 44,497
  • 23
  • 105
  • 176
3
votes
1 answer

Fetching the username who last modified or created the file

Is it possible to get the name of the user who just pasted a file into a folder? A brief overview of what I am trying to do: My application keeps watch on a folder for new files every 10 minutes. If it finds any new file it will upload that file via…
Nishant
  • 905
  • 1
  • 16
  • 36
3
votes
4 answers

File or Folder rename to lower case In C# using DirectoryInfo/FileInfo.MoveTo()

I have a program that renames files or folders to lower case names. I have written this code: private void Replace(string FolderLocation, string lastText, string NewText) { if (lastText == "") { lastText = " "; …
ahmadali shafiee
  • 4,350
  • 12
  • 56
  • 91
3
votes
3 answers

Get FileInfo On Itself?

My C# program is in the form of a single .exe file. Therfore, the user can store it anywhere and name it anything. How can I use the FileInfo class to get its Attributes if I don't know the path?
Sonic42
  • 689
  • 1
  • 14
  • 21
3
votes
3 answers

File size difference between MB and bytes

I'm trying to understand the following issue. I am reading the file info for a file as follows: FileInfo info = new FileInfo(path); The code then returns 16599774 bytes for my file when I do info.Length. When I convert the bytes to MB, I get 15.8…
3
votes
1 answer

FileInfo.Exists not reliable with UNC path

I want to determine if a UNC file exists. I create a FileInfo object, then call FileInfo.Exists. But it'll occasionally return false, even if the file actually exists. How can I accurately determine if a UNC file exists?
Johnsonlu
  • 112
  • 1
  • 10
3
votes
2 answers

FileInfo.OpenRead() - what type of encoding does it use?

I'm using this method to write to a MemoryStream object, which is subsequently stored a binary in SQL. It is being used to read in .HTML files from the file system on Windows. How do I know which type of encoding this data is being read in as?…
Ryan Peters
  • 7,608
  • 8
  • 41
  • 57
3
votes
1 answer

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…
WernerCD
  • 2,137
  • 6
  • 31
  • 51
3
votes
1 answer

FileInfo lock files!

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…
Ferdinando Santacroce
  • 1,047
  • 3
  • 12
  • 31
3
votes
1 answer

Get PHAsset information fast?

I have a method which retrieves information about a PHAsset, and it works, but when it comes to reading information of hundreds of assets it can be quite slow. What is the best way to read information about an asset such as filesize and…
vaid
  • 1,390
  • 12
  • 33
3
votes
1 answer

How to extract file extension from file with no extension with mime type octet-stream?

I have a large amount of files where their original file names have been replaced by ids from my database. For example, what was once name word_document.doc is now 12345. Through a process I have lost the original name. I am now trying to present…
Caleb Doucet
  • 1,751
  • 2
  • 14
  • 29
3
votes
2 answers

getimagesize() vs finfo_file() the exact same for detecting mime type?

Are these functions doing the same checks to detect the mime type of a file? Are there any benefits in choosing one over the other (i.e. terms of reliability/security)?
Stone
  • 343
  • 1
  • 5
  • 11
3
votes
1 answer

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
Daniel Bardsley
3
votes
3 answers

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…
Michael G
  • 6,695
  • 2
  • 41
  • 59