aspnet-ej1-demos/UploadBox/saveFiles.ashx.cs

57 строки
1.7 KiB
C#

#region Copyright Syncfusion Inc. 2001-2022.
// Copyright Syncfusion Inc. 2001-2022. All rights reserved.
// Use of this code is subject to the terms of our license.
// A copy of the current license can be obtained at any time by e-mailing
// licensing@syncfusion.com. Any infringement will be prosecuted under
// applicable laws.
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
namespace WebSampleBrowser.UploadBox
{
/// <summary>
/// Summary description for saveFiles
/// </summary>
public class saveFiles : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string targetFolder = HttpContext.Current.Server.MapPath("uploadfiles");
if (!Directory.Exists(targetFolder))
{
Directory.CreateDirectory(targetFolder);
}
HttpRequest request = context.Request;
HttpFileCollection uploadedFiles = context.Request.Files;
if (uploadedFiles != null && uploadedFiles.Count > 0)
{
for (int i = 0; i < uploadedFiles.Count; i++)
{
string fileName = uploadedFiles[i].FileName;
int indx = fileName.LastIndexOf("\\");
if (indx > -1)
{
fileName = fileName.Substring(indx + 1);
}
//uploadedFiles[i].SaveAs(targetFolder + "\\" + fileName);
}
}
else
{
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
}