แสดงบทความที่มีป้ายกำกับ Asp.net Mvc4 แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ Asp.net Mvc4 แสดงบทความทั้งหมด
วันจันทร์ที่ 18 พฤษภาคม พ.ศ. 2558
Uploading a Folder in Asp.net MVC4
2 ความคิดเห็น:
Posted by
Aagkasit Tontan
at
03:24
Labels:
Asp.net Mvc4,
c#,
Upload Folder,
Uploading a Folder
View
@{
ViewBag.Title = "uploadFolder";
}
upload Folder
ScriptControllor
public ActionResult uploadFolder()
{
return View();
}
[HttpPost]
public async Task UploadHomeReport()
{
try
{
foreach (string file in Request.Files)
{
var fileContent = Request.Files[file];
if (fileContent != null && fileContent.ContentLength > 0)
{
// get a stream
var stream = fileContent.InputStream;
// and optionally write the file to disk
var fileName = fileContent.FileName;
fileName = fileName.Replace(@"/",@"\");
string[] arr = fileName.Split('\\');
//\tculms\sub\sub1
var tempPath = string.Empty;
for (int i = 0; i < arr.Length; i++) {
if (!isFolder(arr[i]))
{
var targetPath = string.Empty;
if (i == 0)
{
targetPath = Path.Combine(Server.MapPath("~/Images"), arr[i]);
tempPath = tempPath + "\\" + arr[i];
if (!System.IO.Directory.Exists(targetPath))
{
System.IO.Directory.CreateDirectory(targetPath);
}
}
else
{
tempPath = tempPath + "\\" + arr[i];
targetPath = Server.MapPath("~/Images") + tempPath;
//targetPath = Path.Combine(Server.MapPath("~/Images"), tempPath);
if (!System.IO.Directory.Exists(targetPath))
{
System.IO.Directory.CreateDirectory(targetPath);
}
}
}
}
var path = Path.Combine(Server.MapPath("~/Images"), fileName);
using (var fileStream = System.IO.File.Create(path))
{
stream.CopyTo(fileStream);
}
}
}
}
catch (Exception)
{
Response.StatusCode = (int)HttpStatusCode.BadRequest;
return Json("Upload failed");
}
return Json("File uploaded successfully");
}
private bool isFolder(string txt) {
var arr = txt.ToCharArray();
for (int i = 0; i < arr.Length;i++ )
{
if (arr[i] == '.') {
return true;
}
}
return false;
}
Web configResult
Derivative
วันจันทร์ที่ 16 กุมภาพันธ์ พ.ศ. 2558
Asp.net Mvc4 Could not load file or assembly 'WebGrease"
ไม่มีความคิดเห็น:
Posted by
Aagkasit Tontan
at
00:38
Labels:
Asp.net Mvc4,
Could not load file or assembly
Could not load file or assembly 'WebGrease, Version=1.5.1.25624, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
answer worked : http://stackoverflow.com/questions/19851912/could-not-load-file-or-assembly-webgrease-version-1-5-1-25624-culture-neutral
answer worked : http://stackoverflow.com/questions/19851912/could-not-load-file-or-assembly-webgrease-version-1-5-1-25624-culture-neutral
สมัครสมาชิก:
ความคิดเห็น (Atom)