fileinfo

C# FileInfo Array to String Array

不羁岁月 提交于 2019-12-24 06:57:08
问题 I have an array that stores files from a directory: string pathToDirectory = @"C:\files"; System.IO.DirectoryInfo diDir = new DirectoryInfo(pathToDirectory); System.IO.FileInfo[] File_Array = diDir.GetFiles(); foreach (FileInfo lfileInfo in File_Array) { } I want to try and convert this array into a string type array instead of a FileInfo type. Please let me know how I can go about doing this. Any help would be greatly appreciated. 回答1: Use static Directory class instead. It returns files as

How to get the drive letter from a full name of the drive

喜欢而已 提交于 2019-12-24 01:06:42
问题 How could the drive letter (e.g. F:\) be obtained from a known full name (if it is present) of a drive (e.g. WORKMEMORYSTICK) using C# under Windows? Even the other way around would be a start. 回答1: The DriveInfo class exposes a method to get all available drives (GetDrives), you could enyumerate these an match your given string. Something like the following ought to help get you there: DirectoryInfo root; var drives = DriveInfo.GetDrives(); foreach (var drive in drives) { if (drive

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

天大地大妈咪最大 提交于 2019-12-23 05:45:05
问题 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 the source and destination Create file listing objects for the source and destination Iterate through the source object, and check to see if it exists in the

Get file size without using System.IO.FileInfo?

三世轮回 提交于 2019-12-21 03:40:53
问题 Is it possible to get the size of a file in C# without using System.IO.FileInfo at all? I know that you can get other things like Name and Extension by using Path.GetFileName(yourFilePath) and Path.GetExtension(yourFilePath) respectively, but apparently not file size? Is there another way I can get file size without using System.IO.FileInfo ? The only reason for this is that, if I'm correct, FileInfo grabs more info than I really need, therefore it takes longer to gather all those FileInfo's

How to get a fully qualified UNC path? [duplicate]

♀尐吖头ヾ 提交于 2019-12-20 02:31:35
问题 This question already has answers here : How to programmatically discover mapped network drives on system and their server names? (7 answers) How do I determine a mapped drive's actual path? (13 answers) Closed 6 years ago . This might be simple and I'm just overlooking something. The FileInfo.FileName of a file lying on a network share returns something like this: H:\Directory1\Dir2\... What I need, though: \\server\share\Directory1\Dir2\... How can I achieve this? 来源: https://stackoverflow

Laravel 4 - no guessers available issue

孤者浪人 提交于 2019-12-19 15:07:17
问题 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 server but I still unable to solve this. What am I missing? Thanks Below are my codes: Models: Product.php class Product extends Eloquent { protected $fillable = array('category_id', 'title', 'description', 'price', 'availability', 'image'); public

Laravel 4 - no guessers available issue

╄→尐↘猪︶ㄣ 提交于 2019-12-19 15:07:11
问题 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 server but I still unable to solve this. What am I missing? Thanks Below are my codes: Models: Product.php class Product extends Eloquent { protected $fillable = array('category_id', 'title', 'description', 'price', 'availability', 'image'); public

Laravel 4 - no guessers available issue

只谈情不闲聊 提交于 2019-12-19 15:06:28
问题 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 server but I still unable to solve this. What am I missing? Thanks Below are my codes: Models: Product.php class Product extends Eloquent { protected $fillable = array('category_id', 'title', 'description', 'price', 'availability', 'image'); public

fileinfo function PHP

不问归期 提交于 2019-12-19 04:53:28
问题 Can someone give me an example of how to use fileinfo , to replace a snippet of code such as: ($_FILES["fileToUpload"]["type"] == "image/gif" || $_FILES["fileToUpload"]["type"] == "image/jpeg" || $_FILES["fileToUpload"]["type"] == "image/png") 回答1: Using this: $finfo = new finfo(); $fileinfo = $finfo->file($file, FILEINFO_MIME); $fileinfo should contain the correct MIME type which you would be able to use in a snippet like that, or in a switch statement like: switch($fileinfo) { case "image

fileinfo function PHP

早过忘川 提交于 2019-12-19 04:53:25
问题 Can someone give me an example of how to use fileinfo , to replace a snippet of code such as: ($_FILES["fileToUpload"]["type"] == "image/gif" || $_FILES["fileToUpload"]["type"] == "image/jpeg" || $_FILES["fileToUpload"]["type"] == "image/png") 回答1: Using this: $finfo = new finfo(); $fileinfo = $finfo->file($file, FILEINFO_MIME); $fileinfo should contain the correct MIME type which you would be able to use in a snippet like that, or in a switch statement like: switch($fileinfo) { case "image