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


C# UploadedFile.GetName方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:selva-osai,项目名称:scheduler,代码行数:26,代码来源:VideoUploadT1.ashx.cs

示例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);
        }
    }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:23,代码来源:VUpload.aspx.cs

示例3: Push

 public void Push(UploadedFile file)
 {
     Package.AddStream(file.InputStream, file.GetName());
 }
开发者ID:angelpetrov90,项目名称:aspnet-sdk,代码行数:4,代码来源:Default.aspx.cs

示例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.";
            }
        }
开发者ID:ezimaxtechnologies,项目名称:ASP.Net,代码行数:66,代码来源:StaffIdentification_Edit.aspx.cs


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