I have the following code to retrieve the duration of a video uploaded:
HttpPostedFileBase postedFileCopy = postedFile;
postedFileCopy.InputStream.Position = 0;
Stream stream = postedFile.InputStream;
LocalResource tempDirectory = RoleEnvironment.GetLocalResource("TempZipDirectory");
postedFile.SaveAs(tempDirectory.RootPath + @"\" + postedFile.FileName);
ShellFile so = ShellFile.FromFilePath(tempDirectory.RootPath + @"\" + postedFile.FileName);
string durationString;
double nanoseconds;
double.TryParse(so.Properties.System.Media.Duration.Value.ToString(),out nanoseconds);
if (nanoseconds > 0)
{
int totalSeconds = (int)Math.Round((nanoseconds / 10000000), 0);
int seconds = totalSeconds % 60;
int minutes = totalSeconds / 60;
int hour = totalSeconds / (60 * 60);
durationString = "" + hour + ":" + minutes + ":" + seconds;
}
else
{
System.Diagnostics.EventLog.WriteEntry("Application", "BLANK DURATION STRING", System.Diagnostics.EventLogEntryType.Error);
durationString = "00:00:00";
}
This works as expected on localhost but when put up to Azure storage it does not seem to be able to retrieve the details of the file. The
postedFile.SaveAs(tempDirectory.RootPath + @"\" + postedFile.FileName);
saves the upload to the directory so i can grab these details but no matter what i try I cant seem to get the nanoseconds returned when the storage is on azure. This is a deployed MVC application and the tempdirectory is stored on the C:/ drive of the server.