0
A
回答
1
public class EventMastersController : Controller
{
private IHostingEnvironment _env;
public EventMastersController(IHostingEnvironment env)
{
_env = env;
}
public void AddFolderAndImage()
{
var webRoot = _env.WebRootPath;
var PathWithFolderName = System.IO.Path.Combine(webRoot, "MyFolder");
if (!Directory.Exists(PathWithFolderName))
{
// Try to create the directory.
DirectoryInfo di = Directory.CreateDirectory(PathWithFolderName);
string Base64String = eventMaster.BannerImage.Replace("data:image/png;base64,", "");
byte[] bytes = Convert.FromBase64String(Base64String);
Image image;
using (MemoryStream ms = new MemoryStream(bytes))
{
image = Image.FromStream(ms);
}
image.Save(PathWithFolderName + "/ImageName.png");
}
}
相關問題
- 1. 從子文件夾讀取圖像並保存到另一個文件夾中
- 2. 將靜態瀏覽器圖像保存到本地文件夾
- 3. Cordova將圖像下載保存到www文件夾中
- 4. 瓶在靜態文件夾
- 5. Vuejs webpack靜態文件夾不在子文件夾中工作
- 6. 到www文件夾
- 7. C#:將圖像保存到文件夾
- 8. 文件保存在Wpf文件夾
- 9. .Net構建和文件保存在App_Code文件夾中
- 10. Rails加載未保存在圖像文件夾中的圖標
- 11. 圖像文件沒有保存到服務器「圖」文件夾
- 12. 上傳圖像並保存在上傳文件夾中
- 13. 使用JAVA上傳圖像並保存在文件夾中
- 14. 如何調整圖像大小並保存在文件夾中?
- 15. NGINX從Ruby文件夾中的子文件夾中提取靜態文件
- 16. 在WebApplication文件夾中存儲圖像
- 17. 限制保存在文檔文件夾中的圖像數
- 18. $ cordovaFile checkFile()查看www文件夾中的文件是否存在?
- 19. 我可以在'res'文件夾中添加什麼文件夾?
- 20. 如何在webscripts主文件夾中添加文件夾
- 21. 將文件保存到文件夾
- 22. 將文件保存到文件夾
- 23. 將文件保存到文件夾
- 24. 文檔文件夾中存在文件
- 25. 我在哪裏爲GWT應用程序添加靜態文件?戰爭文件夾或公共文件夾?
- 26. 保存到程序文件文件夾的文件不存在
- 27. 綁定圖像並保存爲緩存文件夾
- 28. 無法將圖像文件添加到xcode資源文件夾
- 29. 如何將圖像文件保存或移動到包含在我的php文件夾中的文件夾
- 30. 創建文件夾並在其中添加文件
你可以給一個PathWithFolderName的例子 – Isuru