Coolthing Of Theday

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Monday, 25 November 2013

Being smart when opening SkyDrive Smart Files in Desktop app's/ .Net

Posted on 17:41 by Unknown

.NET Framework Blog - Opening Files from SkyDrive using .NET

Summary First;

Summary

SkyDrive for Windows 8.1 introduced a new technology, called smart files. These files can be consumed just like regular files by using Windows Runtime APIs. However, applications that uses System.IO APIs will have problems when opening a smart file unless its content is fully downloaded on the device. With this blog post, we provided you a sample code that invokes Windows.Storage APIs by reflection. This sample code will enable you to write desktop apps that operates on smart files available on Windows 8.1 and also supports running on non-Windows Runtime platforms.

Back to the top;

Since Windows 8 I fell in love with SkyDrive and use it all the time now. Windows 8.1 has improved this a lot by introducing a new concept that requires some changes to the way you interact with files. In, this post Gaye Oncul Kok, Program Manager on the .NET Framework team, explains the key things .NET developers need to know when they read and write files stored on SkyDrive.

SkyDrive for Windows 8.1 introduced a new technology, called smart files, which gives access to the files in the cloud by providing their content on demand. The technology was designed to minimize the disk space utilization on your Windows 8.1 device. You can think of the smart files as the avatars of your cloud files on a device. They have the same appearance as regular files, allowing you to browse, search and do common file operations like viewing the properties or a thumbnail of the file without downloading the full content locally. When you want to open the file, or explicitly want to make it available offline, only then are the file’s contents streamed to your device.

...

image

SkyDrive's placholder files are smaller

From a .NET developers’ perspective, if you are developing a Windows Store App or a desktop app targeting platforms that has Windows Runtime support, your app can consume smart files just like regular files by using Windows.Storage APIs. However, applications that depend on .NET Framework System.IO APIs, such as File.Open() or FileInfo.Open(), will have problems, when operating on a smart file unless its content is fully downloaded on the device. This is due to the fact that the smart files are supported in the Windows Shell layer and above, whereas System.IO APIs resides on the Win32 layer.

If you want your desktop app to run on non-Windows Runtime platforms, such as Windows 7, and also work with SkyDrive smart files available with Windows 8.1 you can either use the related Shell APIs through COM-interop and platform invocations or provide two different implementations and distribute two versions of your app; one for Windows Runtime and the other for non-Windows Runtime platforms. There is a third option, which is provided in sample code. This code uses reflection to utilize Windows.Storage APIs, such as StorageFile.GetFileFromPathAsync and StorageFile.OpenAsync(), if the Windows Runtime types are available on the platform or falls back to System.IO APIs otherwise.

...

Sample Code to Open Smart Files in .NET Desktop Apps

Introduction

SkyDrive for Windows 8.1 introduced a new technology, called smart files, which gives access to the files in the cloud by providing their content on demand.  If you are developing a Windows Store App or a desktop app targeting platforms that has Windows Runtime support, your app can consume smart files just like regular files by using Windows.Storage APIs. However, applications that depend on .NET Framework System.IO APIs, such as File.Open() or FileInfo.Open(), will have problems, when operating on a smart file unless its content is fully downloaded on the device. This is due to the fact that the smart files are supported in the Windows Shell layer and above, whereas System.IO APIs resides on the Win32 layer.

If you want your desktop app to run on non-Windows Runtime platforms, such as Windows 7, and also work with SkyDrive smart files available with Windows 8.1 you can use this sample code to call  using reflection Windows.Storage APIs, such as StorageFile.GetFileFromPathAsync and StorageFile.OpenAsync(), if the Windows Runtime types are available on the platform or falls back to System.IO APIs otherwise.

Building the Sample

The sample contains one solution file: WindowsRuntimeLightup.sln. This solution file includes a single class library project: WindowsRuntimeLightup.csproj that targets .NET 4.5. This project can be built in VS 2012 or VS 2013. Since the calls to Windows Runtime APIs are through reflection,  no special project setting are required for using Windows Runtime APIs. After building the project, the output class library, WindowsRuntimeLightup.dll can be referenced in .NET desktop applications.

Description

This code uses reflection to utilize Windows.Storage APIs, such as StorageFile.GetFileFromPathAsync and StorageFile.OpenAsync(), if the Windows Runtime types are available on the platform or falls back to System.IO APIs otherwise.

The code provides the following public static methods in SmartFileLightUp class:

...

With this sample your app can be automagically adaptive and use the best API for your SkyDrive file access needs.

Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in .Net, Development, Windows7, Windows8, Windows8.1 | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Mr. 7,000! This is my 7,000th post...
    Before this post; After; 20 visits between taking these snaps? Oh wait, that's probably me searching for past related posts....
  • "Windows Server Essentials Media Pack" (DNLA Stream, HTML5 and Dashboard Media stuff)
    Microsoft Downloads - Windows Server Essentials Media Pack This pack enables the media streaming functionality for Windows Server 2012...
  • Rad Gate Post... Get your Red Gate Post here...
    simple talk - Melanie Townsend - Get a copy of the Red Gate Post We recently put together a newspaper of some of the best articles fr...
  • Windows Management Framework 4.0 (PowerShell 4, PowerShell ISE, Management OData, WMI, etc.) now available
    Keith Hill's Blog - PowerShell 4.0 Now Available You can get PowerShell 4.0 for down level operating systems now via the WMF 4.0 d...
  • Viasfora - Your new favorite Visual Studio Text/*ML Editing Extension?
    Winterdom - Introducing Viasfora A couple of days ago, I unveiled Viasfora , my latest attempt at building a decently packaged extensi...
  • "Windows Server [2012 R2]: The Best Infrastructure to Run Linux Workloads"
    In the Cloud - What’s New in 2012 R2: Enabling Open Source Software Part 4 of a 9-part series . ... There are a lot of great s...
  • [Hardware Review] Life with Haswell... Haswell/Harris Beach Intel SDS Ultrabook Review - Part 2
    "So Greg, how's life with Haswell been?" "Pretty Sweet! (Mostly)" I've been given an opportunity to review t...
  • Fuzzy Lookup Add-In for Excel (Insert lame "Fuzzy, wuzzy was an Excel..." snip here)
    Microsoft Downloads - Fuzzy Lookup Add-In for Excel The Fuzzy Lookup Add-In for Excel performs fuzzy matching of textual data in Exce...
  • Caliburn.Micro v1.5.0 released (CM gets Tasks, Async/Await and Share/Setting for RT... and bug fixes of course)
    Caliburn.Micro - Caliburn.Micro v1.5.0 "Release Notes This release fixes many bugs. It also adds support for Task and async/a...
  • Just about everything you ever wanted to know about SQL Server Date and Time Data Types...
    CodeProject - Date and Time Data Types and Functions - SQL Server (2000, 2005, 2008, 2008 R2, 2012) Introduction It would be bette...

Categories

  • .Net
  • 3DPrinting
  • AFeedYouShouldRead
  • Agile
  • ALM
  • Amazon
  • Amiga
  • Analytics
  • Android
  • ASP.NET
  • Azure
  • BigData
  • bing
  • Blogging
  • Book
  • BookReview
  • BUILD
  • C
  • C#
  • C++
  • Career
  • Cat
  • cheatsheet
  • ClickOnce
  • Cloud
  • ComputerHardware
  • css
  • Data
  • DBA
  • DependencyInjection
  • Deployment
  • Design
  • Development
  • devops
  • DVCS
  • ebook
  • EDD
  • Education
  • EnterpriseLibrary
  • EntityFramework
  • Exchange
  • Expression
  • gadget
  • Game
  • GIT
  • Google
  • Government
  • Hadoop
  • hardware
  • HardwareReview
  • HaswellReview
  • HTML5
  • Humor
  • IE
  • IEExtension
  • IfAllElseFails
  • IIS
  • ILMerge
  • Image
  • Infographic
  • interview
  • InversionOfControl
  • Java
  • Javascript
  • Kinect
  • LightSwitch
  • LINQ
  • Linux
  • LosAngeles
  • Lucene
  • Lync
  • MEF
  • Metro
  • MicrosoftOffice
  • MicrosoftOutlook
  • Mono
  • MVC
  • MVVM
  • NetMon
  • NLP
  • NoSQL
  • NuGet
  • OData
  • OneNote
  • OpenXML
  • Paint.Net
  • Personal
  • Photosynth
  • Physics
  • portable
  • Poster
  • PowerShell
  • Preparedness
  • Presentation
  • Prism
  • PrivateCloud
  • RegEx
  • RemoteDesktop
  • Reporting
  • RIAServices
  • Science
  • ScienceFiction
  • Scratch
  • Scrum
  • ServiceBus
  • SharePoint
  • Silverlight
  • SimiValley
  • SPA
  • Space
  • SQLServer
  • Storyboard
  • Surface
  • SVG
  • SystemAdministration
  • T4
  • TeamBuild
  • TeamFoundationServer
  • TechEd
  • Training
  • TypeScript
  • UnitTesting
  • UnityApplicationBlock
  • Utility
  • Veteran
  • VirtualMachine
  • Visio
  • VisualBasic
  • VisualStudio
  • WCF
  • Web X.X
  • Webcast
  • WebFeed
  • WebMatrix
  • Windows
  • Windows7
  • Windows8
  • Windows8.1
  • WindowsHomeServer
  • WindowsLiveWriter
  • WindowsPhone
  • WindowsServer
  • WinRT
  • WiX
  • WMI
  • WOPI
  • WPF
  • XAML
  • XBox360
  • XboxOne
  • zombie

Blog Archive

  • ▼  2013 (500)
    • ►  December (12)
    • ▼  November (61)
      • Red Gate SSMS Ecosystem - The free SQL Server Mana...
      • Two SQL Server Resources that you might want to ta...
      • [Kickstarter of the Day]Making your paper airplane...
      • Infographic for the English Grammar Challenged...
      • Taking File Explorer to 11! (Okay 10... ) - 10 Tip...
      • Creating Per-Monitor DPI-Aware Applications Code S...
      • Windows 8.1 Store App Paper Prototyping Templates
      • Having your Amiga and Pi to... Using Raspberry Pi ...
      • [Humor] Death by Cube...
      • Happy VM Day! The Visual Studio 2013 RTM ALM Virtu...
      • Being smart when opening SkyDrive Smart Files in D...
      • If you're not cheating, you're not... using these ...
      • No If's here.. Jason Haley Web Appifys his Interes...
      • Viasfora - Your new favorite Visual Studio Text/*M...
      • Battling the Console Wars, one mini-3d print job a...
      • [Book Review] 'LÖVE for Lua Game Programming'
      • The TMI Infographic of the day... aka the world's ...
      • Windows Azure Learning Resource Link Round-up
      • Opening EntLib - The Microsoft Enterprise Library ...
      • Office/Exchange File Format,Specification and Prot...
      • Pst... Storing PST's on a network share? Still a n...
      • cough... cough... feeling a little [Xbox One deliv...
      • Surface Pro / Pro 2 Battery Life Extension Tip... ...
      • 1st Annual Socaltech 50 - 50 SoCal Tech companies ...
      • A test lab to play with eDiscovery across Exchange...
      • A word or two or 10 about Word Clouds
      • "Developer's Guide to Microsoft Enterprise Library...
      • New Amiga motherboard, updated AmigaOS... Who says...
      • 10 Professionals, 10 views on the coming trends in...
      • GQL, no, not the Gnome Query Language, the Genome ...
      • Working Office Remote (No that kind of remote...)....
      • [Book Review - Preview] 'LÖVE for Lua Game Program...
      • Nokia Imaging SDK v1.0 RTW now available, official...
      • New from NirSoft - WhoIsConnected[to my darn netwo...
      • Kodu Game Lab v1.4.1.0
      • "Community [e]Book of PowerShell Practices" Septem...
      • Katniss the cat in the kitty remake of The Hunger ...
      • Get your own California Ghost Town, Craigslist'd f...
      • VS2013 powers up with the new and updated Producti...
      • Apple II DOS source code available. All you have t...
      • Jumping into SQL Server 2014 with these two Micros...
      • Amazon goes virtual...desktop.. with their new Ama...
      • Missed Today's Visual Studio 2013 Launch (and ther...
      • "The Field Guide to Data Science" Free eBook of th...
      • Wax poetic with this new WiX Setup Project Editor,...
      • Whoa there's allot of the free NOAA [resources]
      • It's Log Parser Day! Robert Sheldon shows how Log ...
      • Visual Studio / Team Explorer 2013 no longer requi...
      • Preparing Patriotic Presentations with PowerPoint ...
      • Thank you for your thank you's, a veteran's day note
      • Don't Present, Resonate - Nancy Duarte's resonate ...
      • Dave McKinstry's Massive Missive of More VS 2013 L...
      • Drawing for Developers (Yes, you can!)
      • So tasty you'll want to eat your phone, Marmalade ...
      • We're from MSDN Magazine and we're here to help......
      • These beautiful D&D maps make you want to break ou...
      • Write a killer job description so you don't have t...
      • In with the new for the old school, the NNTP bridg...
      • "Windows 8.1 Quick [keyword] Guide for Business(?)"
      • Cloud VDI seems to be the new Dev desktop shiny, s...
      • "hackathon-in-a-box.org" is you're, well, Hackatho...
    • ►  October (65)
    • ►  September (38)
    • ►  August (47)
    • ►  July (75)
    • ►  June (39)
    • ►  May (40)
    • ►  April (42)
    • ►  March (39)
    • ►  February (42)
Powered by Blogger.

About Me

Unknown
View my complete profile