Пример #1
0
        /// <summary>
        /// ファイルの処理
        /// </summary>
        /// <param name="file">ファイル</param>
        private async void HandleFile(File file)
        {
            spservice = new SharePointService();

            // ファイルを SharePointOnline より取得
            var filedata = await spservice.GetContent(file.ServerRelativeUrl);

            // ファイルが編集対象とマーク
            file.InEdit = true;
            // 後で比較するため、現在のファイルサイズを保存
            file.Size = filedata.Length;

            var path = await Xamarin.Forms.DependencyService.Get <IFileService>().SaveFile(file.Name, filedata);

            string type = "";

            // 拡張子からタイプを設定
            string extension = file.Name.Split('.').Count() > 1 ? file.Name.Split('.').Last() : "application/*";

            if (extension == "pptx")
            {
                type = "application/vnd.openxmlformats-officedocument.presentationml.presentation";
            }
            else if (extension == "ppt")
            {
                type = "application/vnd.ms-powerpoint";
            }
            else if (extension == "docx")
            {
                type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
            }
            else if (extension == "xlsx")
            {
                type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            }
            else if (extension == "txt")
            {
                type = "application/txt";
            }

            Xamarin.Forms.DependencyService.Get <IOpenUriService>().OpenFile(path, type);
        }