Menu
  • HOME
  • TAGS

Why is my URI not supported? FileInfo Argumentexception

c#,exception,ftp,uri,fileinfo

Thanks guys, but I already found a solution. The FTP answers you guys are giving me was already in the code, I just had to find the extension of the file. it's solved.

C# FileInfo move foreach

c#,foreach,move,fileinfo

If you would like to iterate multiple items in a directory, you need a DirectoryInfo, not a FileInfo, object. Assuming that you want to get all files in finfo's directory, the code should be like this: foreach (FileInfo filemove in finfo.Directory.EnumerateFiles()) { ... } finfo.Directory gives you DirectoryInfo for finfo's...

Getting x number of files after a certain file

c#,linq,file,fileinfo

You'll want to look into the SkipWhile extension method, the Skip extension method, and then the Take extension method. Additionally, utilize the Directory.EnumerateFiles instead. var files = Directory.EnumerateFiles(pathToFiles, "*.jpg") .Select(x => new FileInfo(x)) .OrderByDescending(x => x.LastWriteTime) .SkipWhile(x => !String.Equals(x.Name, "b.jpg") .Skip(1) .Take(3); Basically, once you have your ordered sequence, skip...

Select Files From Folder Depending on Name Convention

c#,xml,vb.net,fileinfo

private bool IsValid(string value) { string regexString = "^sr-([a-z0-9]+)-([a-z0-9-]+)-matchresults.xml"; return Regex.IsMatch(value, regexString); } This method will give you the files with the specified format (sr-{first_id}-{second_id}-matchresults.xml). Note: your Ids can contain alphanumeric characters also "-" symbol. if you don't want that symbol in id, then code will look like, string regexString...

Why do File.GetLastWriteTimeUtc and FileInfo.LastWriteTime return different values for GMT?

c#,file,datetime,fileinfo

I've actually checked the code in Reflector and they both do the exact same thing, i.e: return DateTime.FromFileTimeUtc((long) data.ftLastWriteTimeHigh << 32 | (long) data.ftLastWriteTimeLow); vs return DateTime.FromFileTimeUtc((long) this._data.ftLastWriteTimeHigh << 32 | (long) this._data.ftLastWriteTimeLow); I've also tested it and dates are the same. You must have accidentally compared Utc with a...

FileInfo in UserSettings saves as Null?

c#,fileinfo,usersettings

You can't. XmlSerializer requires a parameter-less constructor - which FileInfo does not have. It's marked Serializable because there are other serializers that don't have the same requirement. Related question....

How to get true file creation date in R, on Unix systems?

r,filesystems,system-calls,fileinfo

Following other's pointers, this should work quite reasonably. Unfortunately it needs root privileges (dued to debugfs) and it's not very efficient yet (especially a bit quick'n dirty on regular expressions, but it's 01:00 o clock in the morning here :) ). BTW, we set up the pager to be cat...

Trouble specifying destination filename for use in FileInfo.Copy example from MSDN

c#,fileinfo

So sourcePath contains the source path and filename. You can easily construct the destination path from that, like so: // Get just the filename of the source file. var filename = Path.GetFileName(sourcePath); // Construct a full path to the destination by combining the destination path and the filename. var fullDestPath...

How to compare Files in two different Folders and perform conditional copying

c#,file-io,io,directory,fileinfo

You can try this solution, synchronize both directories. class Program { class FileCompare : System.Collections.Generic.IEqualityComparer<System.IO.FileInfo> { public bool Equals(System.IO.FileInfo f1, System.IO.FileInfo f2) { return (f1.Name == f2.Name); } public int GetHashCode(System.IO.FileInfo fi) { string s = fi.Name; return s.GetHashCode(); } } static void Main(string[] args) { string sourcePath = @"C:\Users\Administrator\Desktop\Source";...

Get a certain file extension while getting files based on creation date from a directory

c#,fileinfo,getfiles

Just simple use Where, so code looks like (tested): DirectoryInfo info = new DirectoryInfo(@"C:\tmp"); FileInfo[] files = info.GetFiles() .Where(f=>!(f.FullName.EndsWith("tif"))) .OrderByDescending(p => p.CreationTime) .ToArray(); ...

Why am I getting a “File is open in another process” error in my program?

c#,fileinfo

Because FileInfo.Create opens a stream and you don't close it using(fI.Create()) ; Enclosing the call inside a using statement, also if empty, will ensure that the stream created by the call is closed and disposed...

File type as seen in file's Get Info

osx,cocoa,file-management,fileinfo

You can get the document kind as shown in the Finder using code like this: NSURL* url = [NSURL fileURLWithPath:path]; NSString* documentKind; NSError* error; if ([url getResourceValue:&documentKind forKey:NSURLLocalizedTypeDescriptionKey error:&error]) { // use documentKind here } else { /* handle error */ } However, the document kind is not suitable for...

Displaying image data from folder using Image Created Date criteria?

c#,image,winforms,fileinfo

Play with this: var allfiles = Directory.GetFiles(yoursearchparams..); files = new List<FileInfo>(); foreach(string f in projects) files.Add(new FileInfo(f)); var filesSorted = files.OrderByDescending(x=>x.CreationTime); This is descending and using creation date. There is also OrderBy and LastWriteTime. Here is the full example, including: Setting colorDepth, a text and multiple extensions and using a...

how do i change a file extension on qt

c++,qt,file-extension,fileinfo

Just use rename function from 'stdio.h'. char oldname[] ="XXX.alt"; char newname[] ="XXX.exe"; result= rename( oldname , newname ); if ( result == 0 ) puts ( "File successfully renamed" ); else perror( "Error renaming file" ); ...

Why am I not getting the text from my file with this code?

c#,windows-ce,streamreader,fileinfo,directoryinfo

First, calling CreateDirectory in all cases is a bad idea. It's confusing. Instead, check to see if the directory exists, and if it doesn't then create it and exit the function (because if you created it, you know there's no data). This would have found your error much faster and...

SSIS Read file modification date

sql-server,ssis,fileinfo

You can add a script component to the pipeline which reads the filename from an input variable and writes the file modified date to an output variable: /// <summary> /// This method is called when this script task executes in the control flow. /// Before returning from this method, set...

Get mp3 length in C++ [closed]

c++,mp3,fileinfo

Fortunately for you, it is quite simple to parse the MP3 format. You do not need to decode it, just look at the header. The MP3 does not have a single header like most files, instead a single file is split to many frames (packets) with their own headers which...