How can I tell if a driveItem is a folder? - microsoft-graph-api

I am trying to show an icon for driveItems, in most cases this works by just getting the extension part of the driveItem name.
However, I have files with no extensions, and folders (with no extensions) showing up as the same icon.
Is there a good way using the dotnet Graph SDK to determine if a driveItem is a folder?

driveItem resource has properties folder and file.
folder property is set if the item is a folder.
file property is set if the item is a file.
To determine if the items is either a folder or a file for dotnet Graph SDK check properties folder and file if their are null or have value.
Resources:
driveItem properties

Related

tfignore exclude file path containing a space not working

In my project I have a WCF service reference. The service reference generates some metadata files that have an extension .datasource. I want to ignore/exclude in the tfignore all those files that end with this extension (.datasource) in the folder that contains the service reference.
For some reason VS2017 still shows in my pending changes all the excluded files with the extension .datasource. However, what is strange is that all other files other than this extension do get ignored/excluded. There is one thing of interest though that for the .datasource exclude rule that I have in tfignore, the path consists of a folder/directory that has a space in its name.
Here is that rule in tfignore:
My FolderName/Web.datasource
Is the space in the rule causing the issues? or is it something else?
This .tfignore file will not affect with those files already in source control. You need to remove them from source control first.
Besides if those files already in the pending changes before you add your .tfigonre file in source control. You can try below solution:
If the changes are "still" in pending changes, first create a backup
copy, then make an Undo on them. Close VS, restore the backup copies
and then it should work.
Since .tfignore is similar to .gitignore, if there are space in the middle of folder name, such as My FolderName/Web.datasource, give a try with below format:
My\ FolderName/Web.datasource
For more detail info of .tfignore file rules please refer the official tutorial.

Opening Sibling Files in Document Based iOS App

I want to have a custom project file that a user selects in a UIDocumentBrowserViewController. That project file would then reference files in the same directory which would be opened and written to programmatically. I can't seem to get access to the project's sibling files programmatically (presumably due to sandbox restrictions). What's the best way to get this to work?
I ended up making the enclosing folder a document package, i.e. a folder that shows up in the file browser as a single file. I then had access to read all the files in it.
https://developer.apple.com/library/content/documentation/CoreFoundation/Conceptual/CFBundles/DocumentPackages/DocumentPackages.html

how to add subfolders inside in-app-purchase iOS package?

For some reason, any files I put inside my IAP package (hosted on Apple) under a subfolder, gets eventually downloaded directly under the iOS temporary Contents folder.
I've created a simple IAP package using xcode template which initially had the following directory structure:
projectname/projectname/ContentInfo.plist
I then placed some extra files in the package under a subdir like so:
projectname/projectname/dir1/file1.txt
Then I go to xcode->add files->select dir1 and check "create groups" for added folders. All is ok so far. When I look at xcode, I see a group called "dir1", its location relative to group is "dir1" and full path is correctly set to xxxx/dir1.
I also see "file1.txt" with its location relative to group is "file1.txt" and full path correctly set to xxxx/dir1/file1.txt.
I package everything and upload to Apple.
I run a test to download the package and set a breakpoint after the content has been downloaded. I run a file scan function to list all the files. This is what I see under the xxx.zip/Contents folder that iOS creates:
ContentInfo.plist
file1.txt
dir1 is missing and file1.txt is directly under Contents!
I decided then to reopen the package xcode created (xcarchive) using "Show Package Contents" and indeed I see file1 under Contents/ and not under Contents/dir1...
How do I get the package to retain the directory structure when it's built?
Thanks...
Ah, after several hours, found the answer:
I needed to remove the file and group references and re-create them by "adding files" to the project, selecting dir1 folder with "create folder references", not "create groups" option.
After re-packaging this way, the folders were retained inside the package!

swift ios and geing final grip on copy bundle resources

I am currenly converting an iOS project built in another tool to xcode/swift.
I currently have an xcode swift ios project with multiple targets defined (one for each customer)
For each customer I have a folder "customerxyzassets" that I have added to "target > build phases > copy bundle resources" using the process described here Include a resource directory hierarchy into app bundle
This folder "customerxyzassets" contains subfolders with images and data files which the app is born with.
I would like to grab a path to this folder upon startup, so I can access load datafiles, images etc. from it.
However, the code I have found, e.g. NSBundle.mainBundle, seems to require speciel access to the files through the above. I would rather have raw file access to it. Am i missing something obvious?
It's not clear what you mean here by "special access" or "raw access." NSBundle just returns you paths or URLs so you can directly access the files using normal file APIs.
If you've created a directory structure, then you would generally use pathForResource(_:ofType:inDirectory:) to fetch the path to your specific file. Alternately, you can build a path using NSBundle.resourcePath and append your relative path using stringByAppendingPathComponent. The advantage of the pathForResource methods is that they handle localization for you, and this is preferred unless the resource should never be localized (which is rare).

Unable to see image files in xcode folder reference

I added a folder which contains some images in Xcode as "Create folder references for any added folders". It added the blue folder but it doesn't show the arrow to see its contents.
Is this an issue in Xcode or am I missing something ?
Screenshot :
Blue folder means you added folder reference ,not folder
Right click on the images folder you added and select show in finder...See if the images are there..if not.. you linked the wrong folder
Make sure the search bar at bottom of the file explorer is empty
You have added the folder in a wrong way. To create a reference folder select the checkbox
'Copy items into destination's group folder if needed'
and in folder options select the radio button
"Create folder references for any added folders".
This works.
If you use blue folder references for your resources these folders will also be created inside your application bundle, while resource files in groups will simply be copied to your mainBundle's root directory.
When folder structure is managed outside of XCode (for example, a cross-platform project which has project files for different versions of XCode, Visual Studio and other IDEs, all using mostly the same directory tree), you normally want folder references. Otherwise one would have to recreate every project file every time folder structure changes.
This is Your solution->
if you do want to auto-import newly added files from the file system's folder to this group in XCode, instead of using "Create groups for any added folders", change to "Create folder references to any added folders"

Resources