public static IAsset CreateAssetAndUploadSingleFile(string singleFilePath, AssetCreationOptions assetCreationOptions) { if (!File.Exists(singleFilePath)) { return(null); } //Get original File Name var assetName = Path.GetFileNameWithoutExtension(singleFilePath); //Format file name with adding timestamp string uniqueAssetName = GetTimeStamp.ToString(assetName); if (_context == null) { InitContext(); } IAsset inputAsset = null; try { inputAsset = _context.Assets.Create(uniqueAssetName, assetCreationOptions); // add asset files to this asset var assetFile = inputAsset.AssetFiles.Create(Path.GetFileName(singleFilePath)); assetFile.Upload(singleFilePath); } catch (Exception ex) { throw new Exception(ex.Message); } return(inputAsset); }
private void ProcessComplete(IAsyncResult ar) { string message = "Done"; UpdateMessageInListBox(message); StringBuilder sbLog = new StringBuilder(); foreach (var item in listBox2.Items) { sbLog.AppendLine((string)item); } string LogFilename = GetTimeStamp.ToString("Log") + ".txt"; using (StreamWriter writer = new StreamWriter(LogFilename)) { writer.Write(sbLog); writer.Flush(); } }