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


C# HttpFileCollectionBase.Get方法代码示例

本文整理汇总了C#中System.Web.HttpFileCollectionBase.Get方法的典型用法代码示例。如果您正苦于以下问题:C# HttpFileCollectionBase.Get方法的具体用法?C# HttpFileCollectionBase.Get怎么用?C# HttpFileCollectionBase.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.HttpFileCollectionBase的用法示例。


在下文中一共展示了HttpFileCollectionBase.Get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PopulateFiles

        private void PopulateFiles(HttpFileCollectionBase collection)
        {
            foreach (string fileName in collection.AllKeys)
            {
                var postedFile = collection.Get(fileName);

                if (postedFile != null)
                {
                    m_collection.Add(new UploadedFile(postedFile));
                }
            }
        }
开发者ID:dstarosta,项目名称:GitProjects,代码行数:12,代码来源:UploadedFileCollection.cs

示例2: SaveMultipleFiles

        /// <summary>
        /// Not in use for mobile end i.e. this is not a service for android or ios
        /// </summary>
        /// <param name="collection"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>

        List<string> SaveMultipleFiles(HttpFileCollectionBase collection, string fileName)
        {
            List<string> UniqueFileNames = new List<string>();
            string ext = "";
            string path = HttpContext.Current.Request.PhysicalApplicationPath + "tutorDocs\\";
            if (collection.Count > 0)
            {
                #region LoopFor multipleFiles upload and save and get their names
                for (int i = 0; i < collection.Count; i++)
                {
                    HttpPostedFileBase postedFile = collection.Get(i);
                    ext = Path.GetExtension(postedFile.FileName).ToLower();
                    if (string.IsNullOrEmpty(fileName))
                    {
                        UniqueFileNames.Add(Guid.NewGuid().ToString("n") + ext);
                    }
                    else
                    {
                        if (File.Exists(@path + fileName))
                        {
                            File.Delete(@path + fileName);
                        }
                        UniqueFileNames[i] = fileName;
                    }

                    postedFile.SaveAs(path + UniqueFileNames[i]);

                }
                #endregion


            }

            return UniqueFileNames;
        }
开发者ID:rjdeveloper,项目名称:bigdecimalweb,代码行数:42,代码来源:WebServiceV2Controller.cs

示例3: SaveImage

        string SaveImage(HttpFileCollectionBase collection, string imageName)
        {

            string UniqueFileName = imageName;
            string path = HttpContext.Current.Request.PhysicalApplicationPath + "WebImages\\";

            if (collection.Count > 0)
            {
                if (string.IsNullOrEmpty(imageName))
                {
                    UniqueFileName = Guid.NewGuid().ToString("n") + ".jpg";

                }
                else
                {
                    if (File.Exists(@path + imageName))
                    {
                        File.Delete(@path + imageName);
                    }
                    UniqueFileName = imageName;
                }

                HttpPostedFileBase imgFile = collection.Get(0);
                if (imgFile.ContentType == "image/jpeg" || imgFile.ContentType == "image/png" || imgFile.ContentType == "image/*")
                {
                    Stream requestStream = imgFile.InputStream;
                    Image img = System.Drawing.Image.FromStream(requestStream);

                    img.Save(path + UniqueFileName, System.Drawing.Imaging.ImageFormat.Jpeg);

                    requestStream.Close();

                }
                else
                {
                    if (Constants.isProduction.ToLower() == "true")
                    {
                        Stream requestStream = imgFile.InputStream;
                        Image img = System.Drawing.Image.FromStream(requestStream);
                        img.Save(path + UniqueFileName, System.Drawing.Imaging.ImageFormat.Jpeg);
                        requestStream.Close();
                    }


                }
            }
            return UniqueFileName;
        }
开发者ID:rjdeveloper,项目名称:bigdecimalweb,代码行数:48,代码来源:WebServiceV2Controller.cs

示例4: SaveFile

        /// <summary>
        ///[tutor]  Accepting a student from the tutor
        /// </summary>
        /// <developer>Rishabh </developer>
        /// <param name="objReq"></param>
        /// <returns></returns>
        //[HttpPost]
        //public Response<string> AcceptStudent(StudentTeacherMap objReq)
        //{


        //    Response<string> response = new Response<string>();
        //    List<string> objResp = new List<string>();

        //    try
        //    {
        //        WebMethods obj = new WebMethods();
        //        if (CheckRequestIsvalidornot(this.Request))
        //        {
        //            if (ModelState.IsValid)
        //            {
        //                if (obj.AcceptStudent(objReq))
        //                    response.Create(true, "Student is Accepted", Messages.AppVersion, objResp);
        //                else
        //                    response.Create(false, "The student request you are accepting is already accepted by any other tutor.Please refresh the screen for new request.", Messages.AppVersion, objResp);
        //            }
        //            else
        //                response.Create(false, ModelState.Values.FirstOrDefault().Errors.FirstOrDefault().ErrorMessage, Messages.AppVersion, objResp);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        object session = new JavaScriptSerializer().Serialize(objReq);
        //        LogManager.Error("Error occured while Processing Webservice request :{0}", ex, session, ex.Message);
        //        response.Create(false, Messages.FormatMessage(Messages.ErrorOccure), Messages.AppVersion, objResp);
        //    }

        //    return response;
        //}


        public string SaveFile(HttpFileCollectionBase collection, string fileName)
        {
            string UniqueFileName = "";
            string ext = "";
            string path = HttpContext.Current.Request.PhysicalApplicationPath + "tutorDocs\\";
            if (collection.Count > 0)
            {
                HttpPostedFileBase postedFile = collection.Get(0);
                ext = Path.GetExtension(postedFile.FileName).ToLower();
                if (string.IsNullOrEmpty(fileName))
                {
                    UniqueFileName = Guid.NewGuid().ToString("n") + ext;
                }
                else
                {
                    if (File.Exists(@path + fileName))
                    {
                        File.Delete(@path + fileName);
                    }
                    UniqueFileName = fileName;
                }

                postedFile.SaveAs(path + UniqueFileName);
            }

            return UniqueFileName;
        }
开发者ID:rjdeveloper,项目名称:bigdecimalweb,代码行数:68,代码来源:WebServiceController.cs


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