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
11
votes
2 answers

Caching FileInfo properties in C#

From the MSDN documentation for the FileInfo.Name property, I see that the data for the property is cached the first time it is called and will only be updated subsequently by using the Refresh method. I've the following questions which I can't find…
Iain Sproat
  • 5,210
  • 11
  • 48
  • 68
10
votes
3 answers

How to use Directory.EnumerateFiles excluding hidden and system files

I'm enumerating all files in a directory so that I can process them later. I want to exclude hidden and system files. This is what I have so far: IEnumerable> files; files = Directory.EnumerateFiles(sourcePath, "*",…
Equalsk
  • 7,954
  • 2
  • 41
  • 67
9
votes
3 answers

Laravel 4 - no guessers available issue

I get this error: LogicException: Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?) while trying to upload an image. I have enabled the php_fileinfo extension and also restarted the Wamp web…
user3227412
  • 187
  • 1
  • 2
  • 16
9
votes
2 answers

How to check whether a MIME type is of JPG, PNG, BMP or GIF?

I have written this code: $filename = "some/path/where/the/file/can/be/found.some_extension"; $buffer = file_get_contents($filename); $finfo = new finfo(FILEINFO_MIME_TYPE); var_dump($finfo->buffer($buffer)); finfo_close($finfo); Possible outputs…
Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
9
votes
2 answers

Create an Empty FileInfo Object in C# without an existing file

I added an alternative code-path using an input string rather than reading from a file. I would require an empty FileInfo object as I have many instances which access the Name, Length and Extension property. Ideally I am looking for something like…
Lorenz Lo Sauer
  • 23,698
  • 16
  • 85
  • 87
8
votes
4 answers

DirectoryInfo GetFiles TOP number

I want to return 10 files only from a directory. Is this possible? DirectoryInfo d = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/xml")); FileInfo[] files = d.GetFiles("*.xml"); This way returns all XML files, but I want to get just the…
Beginner
  • 83
  • 1
  • 3
8
votes
3 answers

Is it safe to create a FileInfo on a file that is currently being written to?

In my application (C# 4.5 winforms app) I periodically check the contents of a folder and store the details of any files found into a database. Within this routine, I create a FileInfo instance using new FileInfo(path), and I read the properties…
wwarby
  • 1,873
  • 1
  • 21
  • 37
7
votes
3 answers

Determining Filetype with PHP. What is Magic Database?

I'm trying to determine if some files are actually images (using PHP). I've been advised to use finfo and i'm trying to understand how it works. What I don't get is - what is a magic numbers database and how does it work? I'm a bit puzzled - does…
Stann
  • 13,518
  • 19
  • 65
  • 73
7
votes
1 answer

C# - Add, edit and delete tags of file

I would like to add and retrieve tags of files in File System. As you can tag Stackoverflow question to the relevant topics, you can tag a file in Windows file-system: The following way doesn't give me access to the tags of the file, but only…
user3165438
  • 2,631
  • 7
  • 34
  • 54
7
votes
3 answers

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…
Axarydax
  • 16,353
  • 21
  • 92
  • 151
7
votes
5 answers

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…
Ty Norton
  • 319
  • 5
  • 14
7
votes
4 answers

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…
Adam Haile
  • 30,705
  • 58
  • 191
  • 286
7
votes
1 answer

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…
Colin Desmond
  • 4,824
  • 4
  • 46
  • 67
6
votes
1 answer

Is there a way to get the original link from which a file was download to Python?

On Mac OS, when you "Get Info" from a file, in "More info", there's a "Where from" information that shows me the original url from where I download the file. I want to get to this information using Python, and I cannot seem to find a way to do…
6
votes
4 answers

File Info PHP Error - Class 'finfo' not found but the module is in php.ini

I am having a problem getting File Info working. It is enabled in PHP.ini but when I run a php -m it is not listed. I have PHP 5.5 so it should be standard and not need the pecl. I am a newbie and confused so please be kind. php -m [PHP…
Chris
  • 195
  • 1
  • 4
  • 17
1
2
3
24 25