1
イメージをフォルダに保存したい。そのために、私は "D:\ Project \ Site \ ImageFiles"としてフォルダのパスを与えます。このパスを使用すると、イメージをフォルダに正常に保存できました。パスにアクセスするには?
これでパスを ".. \ Project \ Site \ ImageFiles"として保存します。ここで
はコードです:
public static bool SaveOriginalImage(string imageName, Image image)
{
try
{
var imageLocation = "D:\Project\Site\ImageFiles\";
if (!Directory.Exists(imageLocation))
{
Directory.CreateDirectory(imageLocation);
}
imageLocation = imageLocation + imageName;
var bitMapImage = new Bitmap(image.Width, image.Height);
bitMapImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
using (var graphicImageContent = Graphics.FromImage(bitMapImage))
{
graphicImageContent.CompositingQuality = CompositingQuality.HighQuality;
graphicImageContent.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphicImageContent.SmoothingMode = SmoothingMode.HighQuality;
graphicImageContent.DrawImage(image, 0, 0, image.Width, image.Height);
}
bitMapImage.Save(imageLocation);
bitMapImage.Dispose();
return true;
}
catch (Exception ex)
{
return false;
}
}
".. \プロジェクト\サイト\ ImageFiles \" などのパスを与えたとき、私は例外「アクセスがパスのために拒否され得る.. \プロジェクト\サイト\ ImageFiles \ "ディレクトリを作成します。
どうすれば実現できますか?
2つの可能性:私は理解できないことができ、ロマーノZumbé@アプリケーション –
を起動するユーザのために(例えば、管理者など)以上のアクセス権を使用してアプリケーションを起動するか、またはパスへのアクセス権限を設定あなたの答え。あなたはもう一度伝えることができますか? –
このリンクを確認してください[https://stackoverflow.com/questions/4877741/access-to-the-path-is-denied](https://stackoverflow.com/questions/4877741/access-to-the-path -is-denied) – user2156791