How to identify the path is a folder or file in metro c++ ?


  • In c#,  we can use  Directory.Exists(path)   and  File.Exists(path)   to check the path is a folder or file .

    Is there any way to achieve  this  in metro c++ ??

    Thanks for your help.

    Friday, August 24, 2012 11:40 AM


  • Why do you need this? What scenario are you trying to achieve? There may be a better way.

    In general your app won't deal with paths and files, the app will deal with StorageFolders and StorageFile objects. An app has direct access only to its install and application data directories, and it cannot see or manipulate the file system elsewhere.

    Your app can get brokered access to other directories (e.g. libraries declared with capabilities, user selected folders via the FolderPicker) through StorageFile and StorageFolder objects. When you use these, the broker process does the actual file access on your behalf. The data within the file is provided to the app via a stream returned from StorageFile::OpenAsync.

    See Accessing data and files for more information.

    All that said, given a path that the app can read you can try loading into a StorageFile or StorageFolder with StorageFile.GetFileFromPathAsync or StorageFolder.GetFolderFromPathAsync and see if the call succeeds. You can check the Attributes on the object to see if it is a folder.


    Monday, August 27, 2012 7:17 AM