当前位置: 首页>>代码示例>>C#>>正文


C# File.Length方法代码示例

本文整理汇总了C#中File.Length方法的典型用法代码示例。如果您正苦于以下问题:C# File.Length方法的具体用法?C# File.Length怎么用?C# File.Length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在File的用法示例。


在下文中一共展示了File.Length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetImageSize

        public static AccidentMediaViewModel GetImageSize(string fileName)
        {

            var options = new BitmapFactory.Options
            {
                InJustDecodeBounds = true
            };

            File file = new File(fileName);
            long lengthMB = file.Length() / 1024;

            BitmapFactory.DecodeFile(fileName, options);
            int width = options.OutWidth;
            int height = options.OutHeight;
            string type = options.OutMimeType;

           
            file.Dispose();
            return new AccidentMediaViewModel
            {
                Height = height,
                MimeType = type,
                Filename = fileName,
                SizeKb = lengthMB,
                Width = width
            };

        }
开发者ID:Railgun-it,项目名称:autoresolve-app,代码行数:28,代码来源:ImageExtensions.cs

示例2: IncludeFile

		/**
     	* Add a representation of a file to a cursor.
     	*
     	* @param result the cursor to modify
     	* @param docId  the document ID representing the desired file (may be null if given file)
     	* @param file   the File object representing the desired file (may be null if given docID)
     	*/
		void IncludeFile (MatrixCursor result, string docId, File file)
		{
			if (docId == null) {
				docId = GetDocIdForFile (file);
			} else {
				file = GetFileForDocId (docId);
			}

			DocumentContractFlags flags = (DocumentContractFlags)0;

			if (file.IsDirectory) {
				// Request the folder to lay out as a grid rather than a list. This also allows a larger
				// thumbnail to be displayed for each image.
				//            flags |= Document.FLAG_DIR_PREFERS_GRID;

				// Add FLAG_DIR_SUPPORTS_CREATE if the file is a writable directory.
				if (file.IsDirectory && file.CanWrite ()) {
					flags |=  DocumentContractFlags.DirSupportsCreate;
				}
			} else if (file.CanWrite ()) {
				// If the file is writable set FLAG_SUPPORTS_WRITE and
				// FLAG_SUPPORTS_DELETE
				flags |= DocumentContractFlags.SupportsWrite;
				flags |= DocumentContractFlags.SupportsDelete;
			}

			string displayName = file.Name;
			string mimeType = GetTypeForFile (file);

			if (mimeType.StartsWith ("image/")) {
				// Allow the image to be represented by a thumbnail rather than an icon
				flags |= DocumentContractFlags.SupportsThumbnail;
			}

			MatrixCursor.RowBuilder row = result.NewRow ();
			row.Add (DocumentsContract.Document.ColumnDocumentId, docId);
			row.Add (DocumentsContract.Document.ColumnDisplayName, displayName);
			row.Add (DocumentsContract.Document.ColumnSize, file.Length ());
			row.Add (DocumentsContract.Document.ColumnMimeType, mimeType);
			row.Add (DocumentsContract.Document.ColumnLastModified, file.LastModified ());
			row.Add (DocumentsContract.Document.ColumnFlags, (int)flags);

			// Add a custom icon
			row.Add (DocumentsContract.Document.ColumnIcon, Resource.Drawable.icon);
		}
开发者ID:BratislavDimitrov,项目名称:monodroid-samples,代码行数:52,代码来源:MyCloudProvider.cs


注:本文中的File.Length方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。