Showing posts with label file. Show all posts
Showing posts with label file. Show all posts

Tuesday, April 8, 2014

Get latest Directory from the Directory in C#

You can get latest file or folder path from this function

public string getLatestDirectory(string path, string folderName)
{
            FileInfo[] info = Directory.GetDirectories(path + "\\"+folderName).Select(x => new FileInfo(x)).OrderByDescending(x => x.LastWriteTime).Take(1).ToArray();
            return Path.GetFullPath(info[0].Name);
}

Tuesday, March 25, 2014

Attach external file in excel sheet by C#

Just add file in your worksheet by following code

ws.Shapes.AddOLEObject(Filename: @"c:\data\filename.pdf", Height: 10, Width: 10, Top: 150, Left: 300);