How To Upload File In C#, asp.net ,MVC and Create Directory If Not Exist

How To Upload File In C#, asp.net ,MVC and Create Directory If  Not Exist








using System;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Mvc;
using System.Collections.Generic;

namespace myProject
{
    public static class Utils

    {


public static bool SaveFile(HttpPostedFile postedFile, string filePath, string fileName)
        {


            if (!Directory.Exists(filePath))
            {
                Directory.CreateDirectory(filePath);
            }

            if (postedFile.ContentLength > 0)
            {
                postedFile.SaveAs(filePath + fileName);
                return true;
            }
            else
            {
                return false;
            }
        }
  }
}

No comments:

Post a Comment

Thank You For Your Great Contribution

Featured Post

how to post formdata or http.context.form data from angular 6 to asp.net mvc web api or api using Token based authentication with header

how to post formdata or http.context.form data from angular 6 to asp.net mvc web api or api using Token based authentication with header  ...

Popular Posts