Inside and Out…

An attempt to understand technology better…

CERapi – Working with files using CEFile

Posted by Gaurav Khanna on March 3, 2005

I am nearing the completion of implementing the CEFile class that will represent a file on the Windows CE device:

CEFile file = newCEFile(“\\My documents\\myfile.txt“);

Once the object is created, we can get various details of the file, like its attributes, size, amongst other things. Also, we can move or copy the file within the device or to the desktop. In addition, functionality has been added to launch the object. The Launch method of CEFile will attempt to open the file present on the device using the shell file-type associations. Below is a snippet as to how the CEFile object can be worked upon:

Console.WriteLine(“Filename: {0}”,file.Path); // complete path including the file name

Console.WriteLine(“Folder: {0}”,file.Folder);

Console.WriteLine(“File: {0}”,file.Filename); // only the file name

Console.WriteLine(“Archive: {0}”,file.IsArchive.ToString());

Console.WriteLine(“Created on: {0}”,file.CreationTime.ToString());

Console.WriteLine(“LastAccessed on: {0}”,file.LastAccessTime.ToString());

Console.WriteLine(“LastWritten on: {0}”,file.LastWriteTime.ToString());

Console.WriteLine(“Size: {0}”,file.Size.ToString());

Console.WriteLine(“OID on: {0}”,file.OID.ToString());

Console.WriteLine(“LaunchFile: {0}”,file.Launch().ToString());

Console.WriteLine(“CopyToDesktop: {0}”,file.CopyTo(CEFileSystemDestination.ToDesktop,

“c:\\”+arrFiles[0]).ToString());

Console.WriteLine(“MoveFile:{0}”,file.MoveTo(CEFileSystemDestination.WithinDevice,

rootFolder.Path+”\\Newfile.txt”).ToString());

Console.WriteLine(“DeleteFile: {0}”,file.Delete());

Hopefully, by the end of this week, I will be able to release the updated component 🙂

Leave a comment