Praeclarum.App.DocumentReference.New C# (CSharp) Method

New() public static method

public static New ( string directory, string baseName, string ext, IFileSystem fs, DocumentConstructor dctor, string contents = null ) : Task
directory string
baseName string
ext string
fs IFileSystem
dctor DocumentConstructor
contents string
return Task
		public static async Task<DocumentReference> New (string directory, string baseName, string ext, IFileSystem fs, DocumentConstructor dctor, string contents = null)
		{
			if (ext [0] != '.') {
				ext = '.' + ext;
			}

			//
			// Get a name
			//
			var n = baseName + ext;
			var i = 1;
			var p = Path.Combine (directory, n);
			var files = await fs.ListFiles (directory);
			while (files.Exists (x => x.Path == p)) {
				i++;
				n = baseName + " " + i + ext;
				p = Path.Combine (directory, n);
			}

			return new DocumentReference (await fs.CreateFile (p, contents), dctor, isNew: true);
		}

Same methods

DocumentReference::New ( string path, string defaultExt, IFileSystem fs, DocumentConstructor dctor, string contents = null ) : Task