本文整理汇总了C#中UploadedFile.GetName方法的典型用法代码示例。如果您正苦于以下问题:C# UploadedFile.GetName方法的具体用法?C# UploadedFile.GetName怎么用?C# UploadedFile.GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UploadedFile
的用法示例。
在下文中一共展示了UploadedFile.GetName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertImage
public int InsertImage(UploadedFile file, int userID)
{
string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["TelerikConnectionString35"].ConnectionString;
using (SqlConnection conn = new SqlConnection(connectionString))
{
string cmdText = "INSERT INTO AsyncUploadImages VALUES(@ImageData, @ImageName, @UserID) SET @Identity = SCOPE_IDENTITY()";
SqlCommand cmd = new SqlCommand(cmdText, conn);
byte[] imageData = GetImageBytes(file.InputStream);
SqlParameter identityParam = new SqlParameter("@Identity", SqlDbType.Int, 0, "ImageID");
identityParam.Direction = ParameterDirection.Output;
cmd.Parameters.AddWithValue("@ImageData", imageData);
cmd.Parameters.AddWithValue("@ImageName", file.GetName());
cmd.Parameters.AddWithValue("@UserID", userID);
cmd.Parameters.Add(identityParam);
conn.Open();
cmd.ExecuteNonQuery();
return (int)identityParam.Value;
}
}
示例2: LooongMethodWhichUpdatesTheProgressContext
private void LooongMethodWhichUpdatesTheProgressContext(UploadedFile file)
{
const int total = 100;
RadProgressContext progress = RadProgressContext.Current;
for (int i = 0; i < total; i++)
{
progress["SecondaryTotal"] = total.ToString();
progress["SecondaryValue"] = i.ToString();
progress["SecondaryPercent"] = i.ToString();
progress["CurrentOperationText"] = file.GetName() + " is being processed...";
if (!Response.IsClientConnected)
{
//Cancel button was clicked or the browser was closed, so stop processing
break;
}
//Stall the current thread for 0.1 seconds
System.Threading.Thread.Sleep(100);
}
}
示例3: Push
public void Push(UploadedFile file)
{
Package.AddStream(file.InputStream, file.GetName());
}
示例4: UpdatePhoto
protected void UpdatePhoto(object sender, EventArgs e)
{
if (ruUserImage.UploadedFiles.Count > 0)
{
newFile = ruUserImage.UploadedFiles[0];
/* is the file name of the uploaded file 50 characters or less?
* The database field that holds the file name is 50 chars.
* */
if (newFile.ContentLength > AppSettings.ProfileImageMaxFileSize)
{
lblUpdateResults.Text = "The file being imported is too big. Please select another file.";
}
else
{
if (newFile.GetName().Length <= AppSettings.ProfileImageMaxFileNameLength)
{
var uploadFolder = Server.MapPath(AppSettings.ProfileImageUserWebPath);
string newFileName;
do
{
newFileName = (Path.GetRandomFileName()).Replace(".", "") +
newFile.GetExtension();
} while (System.IO.File.Exists(Path.Combine(uploadFolder, newFileName)));
try
{
newFile.SaveAs(Path.Combine(uploadFolder, newFileName));
var oUser = SessionObject.LoggedInUser;
var successful = oUser.UpdateUserImageFilename(newFileName);
if (successful)
{
//attempt to delete the old file
if (imgPhoto.Src != "/Images/person.png")
{
var oldFilePath = Server.MapPath(imgPhoto.Src);
File.Delete(oldFilePath);
}
oUser.ImageFilename = newFileName;
SessionObject.LoggedInUser = oUser;
imgPhoto.Src = AppSettings.ProfileImageUserWebPath + "/" + newFileName;
}
else
{
lblUpdateResults.Text = "Database error. Please contact system administrator.";
}
}
catch (Exception ex)
{
lblUpdateResults.Text = "Image Import unsuccessful. Please contact system adminstrator.";
}
}
else
{
lblUpdateResults.Text = "Image filename length must be 50 characters or less. Please rename the file and try again.";
}
}
}
else
{
lblUpdateResults.Text = "Image import unsuccessful. No image specified.";
}
}