Questions tagged [system.io.fileinfo]

77 questions
169
votes
4 answers

Converting file into Base64String and back again

The title says it all: I read in a tar.gz archive like so break the file into an array of bytes Convert those bytes into a Base64 string Convert that Base64 string back into an array of bytes Write those bytes back into a new tar.gz file I can…
darkpbj
  • 2,892
  • 4
  • 22
  • 32
19
votes
7 answers

How to use FileInfo object from Powershell

I am now starting to use PowerShell and after a lot of time using the Unix shells and want to know how to check for the existence of a file or directory. In Powershell why does Exist return false in the following expression? PS H:\>…
BeWarned
  • 2,280
  • 1
  • 15
  • 22
6
votes
3 answers

System.IO.FileInfo and Relative Paths

I was wondering if someone could help me understand why does System.IO.FileInfo behaves differently on Windows than on Linux when handling relative paths. Example On Linux PS /home/user/Documents>…
Santiago Squarzon
  • 41,465
  • 5
  • 14
  • 37
6
votes
5 answers

Measuring fileinfo.Length objects into kbs

I have the following code: foreach (string p in dirs) { string path = p; string lastAccessTime = File.GetLastAccessTime(path).ToString(); bool DirFile = File.Exists(path); FileInfo fInf = new…
yeahumok
  • 2,940
  • 19
  • 52
  • 63
5
votes
1 answer

Why won't a DirectoryInfo instance (re)create a folder after deleting it?

I'm assuming .NET DirectoryInfo and FileInfo objects are similar to Java's java.io.File, i.e. they represent abstract paths and aren't necessarily connected to existing physical paths. I can do what I'm trying to do (empty out a folder and create it…
Dan Novak
  • 634
  • 2
  • 7
  • 15
4
votes
3 answers

How do I tell my C# application to close a file it has open in a FileInfo object or possibly Bitmap object?

So I was writing a quick application to sort my wallpapers neatly into folders according to aspect ratio. Everything is going smoothly until I try to actually move the files (using FileInfo.MoveTo()). The application throws an exception:…
Evan C
  • 41
  • 1
  • 1
  • 2
4
votes
1 answer

Powershell's Get-ChildItem cannot see OneDrive's Online-Only files

How to retrieve in Powershell the file info of Windows 8.1's special kind of OneDrive files, the Online-only files? While Windows Explorer provides the typical file info (like date modified, file type, and size) for all files on OneDrive,…
wfr
  • 155
  • 9
3
votes
1 answer

FileInfo.Length always show a files total size, not actual current size

I am trying to monitor the progress of a large file copy proceedure (without manually copying the bytes of data myself) using the File.Copy([FileName]) command. So what I am trying to do is get the length of the file being copied, and compare that…
buzzluck68
  • 31
  • 2
3
votes
1 answer

FileInfo.IsReadOnly versus FileAttributes.ReadOnly

Is there any difference between these two ways of checking whether a file is read-only? Dim fi As New FileInfo("myfile.txt") ' getting it from FileInfo Dim ro As Boolean = fi.IsReadOnly ' getting it from the attributes Dim ro As Boolean =…
jor
  • 2,058
  • 2
  • 26
  • 46
3
votes
3 answers

How to read all CSV in a folder

I have a little piece of code in which I can read a CSV file and then my code converts the accounts in the CSV file to IBAN accounts. Somehow this gives me an error: using (var client = new WebService.BANBICSoapClient("IBANBICSoap")) { …
Matheno
  • 4,112
  • 6
  • 36
  • 53
3
votes
3 answers

c# copying files from source folder to target folder

Source and Target have the same subdirectories like this : c:\fs\source\a\ c:\fs\source\b\ c:\fs\target\a\ c:\fs\target\b\ I am battling with copying files from source to target if not existing files. What is the best way in C# to compare source…
3
votes
1 answer

Getting the size of a file that exceeds System.Int64 range (theoretically possible)

To find out the length of a file (in bytes) you would normally use FileInfo.Length or System.IO.Stream.Length (is there a difference?). Both are of type long, i.e. System.Int64, hence the maximal possible value is: 9 223 372 036 854 775 807 Now it…
w128
  • 4,680
  • 7
  • 42
  • 65
2
votes
1 answer

Deleting files after copying kills application

I found a very weird bug when using FileInfo.Delete() or Directory.Delete(path, true) after copying a folder. Problem: Copy a folder containing many files and a few subfolders recursively Try to delete the original folder recursively Exactly on the…
Daniel Möller
  • 84,878
  • 18
  • 192
  • 214
2
votes
1 answer

"Best" way to access IO.FileInfo Protected property (OriginalPath)?

I'm working on a series of methods that will test a given path to determine if it is (or, at least could be) valid. I have a couple of overloads that will accept either an IO.FileInfo object or an IO.DirectoryInfo object - which I'd personally…
G_Hosa_Phat
  • 976
  • 2
  • 18
  • 38
2
votes
2 answers

.SQL files in visual studio 2012

I have an question about executin of sql commands from visual studio, I have a few procedures which are not so short so it would be a drag if i execute them with comandtype text and write it with stringbuilder. I decided to write them in .sql file…
1
2 3 4 5 6