Exemple #1
0
        private static System.IO.FileAttributes ConvertFileAttributes(WinRTFileAttributes fileAttributes)
        {
            //namespace Windows.Storage
            //{
            //    [Flags]
            //    public enum FileAttributes
            //    {
            //        Normal = 0,
            //        ReadOnly = 1,
            //        Directory = 16,
            //        Archive = 32,
            //        Temporary = 256,
            //        LocallyIncomplete = 512,
            //    }
            //}

            //namespace System.IO
            //{
            //    [Flags]
            //    public enum FileAttributes
            //    {
            //        ReadOnly = 1,
            //        Hidden = 2,
            //        System = 4,
            //        Directory = 16,
            //        Archive = 32,
            //        Device = 64,
            //        Normal = 128,
            //        Temporary = 256,
            //        SparseFile = 512,
            //        ReparsePoint = 1024,
            //        Compressed = 2048,
            //        Offline = 4096,
            //        NotContentIndexed = 8192,
            //        Encrypted = 16384,
            //    }
            //}

            // Normal is a special case and happens to have different values in WinRT and Win32.
            // It's meant to indicate the absense of other flags.  On WinRT this logically is 0,
            // however on Win32 it is represented with a discrete value of 128.
            return((fileAttributes == WinRTFileAttributes.Normal) ?
                   FileAttributes.Normal :
                   (FileAttributes)fileAttributes);
        }
Exemple #2
0
        /// <summary>
        /// Asynchronously sets file attribute flags on this file.
        /// </summary>
        /// <param name="file">The file to modify.</param>
        /// <returns></returns>
        public static async Task SetFileAttributesAsync(this StorageFile file, FileAttributes attributes)
        {
            string[] propertyList = new string[] { FileAttributesKey };
            IDictionary <string, object> props = await file.Properties.RetrievePropertiesAsync(propertyList)
                                                 .AsTask().ConfigureAwait(false);

            if (props != null)
            {
                props[FileAttributesKey] = (uint)props[FileAttributesKey] | (uint)attributes;
            }
            else
            {
                props = new PropertySet
                {
                    { FileAttributesKey, (uint)attributes }
                };
            }

            await file.Properties.SavePropertiesAsync(props);
        }
        public async void TextProperty(ClassListStroce cc)
        {
            var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();



            // Get file's basic properties.
            Windows.Storage.FileProperties.BasicProperties basicProperties =
                await(await StorageFile.GetFileFromPathAsync(cc.Path)).GetBasicPropertiesAsync();


            string fileSize = string.Format("{0:n0}", basicProperties.Size);


            Windows.Storage.FileAttributes folderAttributes = (await StorageFile.GetFileFromPathAsync(cc.Path)).Attributes;

            if ((folderAttributes & Windows.Storage.FileAttributes.ReadOnly) == Windows.Storage.FileAttributes.ReadOnly)
            {
                Debug.WriteLine("The item is read-only.");
            }

            if ((folderAttributes & Windows.Storage.FileAttributes.Directory) == Windows.Storage.FileAttributes.Directory)
            {
                Debug.WriteLine("The item is a folder.");
            }

            if ((folderAttributes & Windows.Storage.FileAttributes.Archive) == Windows.Storage.FileAttributes.Archive)
            {
                Debug.WriteLine("The item is archived.");
            }

            if ((folderAttributes & Windows.Storage.FileAttributes.Temporary) == Windows.Storage.FileAttributes.Temporary)
            {
                Debug.WriteLine("The item is temporary.");
            }


            textName.Text = resourceLoader.GetString("NameText") + ": " + (await StorageFile.GetFileFromPathAsync(cc.Path)).Name;
            var thumbnaildstorageFolder = await(await StorageFile.GetFileFromPathAsync(cc.Path)).GetScaledImageAsThumbnailAsync(ThumbnailMode.SingleItem, 40, ThumbnailOptions.UseCurrentScale);

            // MessageDialog messageDialog = new MessageDialog(fileProperties.ToString(), resourceLoader.GetString("InfoText"));
            //await messageDialog.ShowAsync();
            this.Title = resourceLoader.GetString("InfoText");
            BitmapImage          image     = null;
            StorageItemThumbnail thumbnail = (StorageItemThumbnail)thumbnaildstorageFolder;

            image = new BitmapImage();
            image.SetSource(thumbnail);
            img.Source = image;



            textTip.Text  = resourceLoader.GetString("TipText") + ": ";
            textTip1.Text = (await StorageFile.GetFileFromPathAsync(cc.Path)).DisplayType;

            textpath.Text  = resourceLoader.GetString("PathText") + ": ";
            textpath1.Text = (await StorageFile.GetFileFromPathAsync(cc.Path)).Path;

            textcreate.Text  = resourceLoader.GetString("CreatText") + ": ";
            textcreate1.Text = (await StorageFile.GetFileFromPathAsync(cc.Path)).DateCreated.ToString();
            textizm.Text     = resourceLoader.GetString("IzmenText") + ": ";
            textizm1.Text    = basicProperties.DateModified.ToLocalTime().ToString();

            textsize.Text  = resourceLoader.GetString("SizeText") + ": ";
            textsize1.Text = GetFileSize(basicProperties);
        }