Free Support Forum - groupdocs.com

File couldn't be found


#1

Okay, now following this documentation

http://groupdocs.com/docs/display/conversionnet/How+to+use+GroupDocs+Conversion+for+.NET+in+an+ASP.NET+MVC+Project
I developed an application but I am getting this error
I placed sample.pdf in App_Data folder and added App_Data folder as path in global.asax.cs

#2

Hello,


We are sorry to hear that you have such issue. Please share with us next:
1. Full code of the controller.
2. Full code of the globals.
3. Full code of the web config.
4.Full code of the View

Thank you.

#3

There is no code to put in view in the documentation so my view is empty, similarly there is no code to put in web.config, so it’s as it is

global
protected void Application_Start()
{

//GroupdocsConversion.SetLicensePath();
GroupdocsConversion.SetRootStoragePath("~/App_Data/");
GroupdocsConversion.Init();// initialize Conversion control

AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
controller
using Groupdocs.Common;
using Groupdocs.Web.UI.Conversion;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace DocConversion.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
var conversion = GroupdocsConversion.Instance();
var convertResult = conversion.Convert("@/App_Data/sample.pdf", “converted\converted.jpg”, FileType.Jpg);
if (convertResult.Result)
{
// file is converted and can be downloaded
Download(convertResult.ConvertedFileName);
}
return View();
}

public ActionResult About()
{
ViewBag.Message = “Your application description page.”;

return View();
}

private void Download(string outputFileName)
{
FileType fileType;
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.ClearContent();
response.Clear();
String extension = Path.GetExtension(outputFileName);
if (extension != null && Enum.TryParse(extension.Remove(0, 1), true, out fileType))
{ response.ContentType = Groupdocs.Utils.MimeTypeMapper.Map(fileType); }
response.AddHeader(“Content-Disposition”, “attachment; filename=”" + Path.GetFileName(outputFileName) + “”");
response.TransmitFile(outputFileName);
response.Flush();
response.End();
}

public ActionResult Contact()
{
ViewBag.Message = “Your contact page.”;

return View();
}
}
}

#4

Hello,


Thank you for the code. Here what you should change:

1. GroupdocsConversion.SetRootStoragePath("~/App_Data/"); - change to GroupdocsConversion.SetRootStoragePath(Server.MapPath("~/App_Data/"));

2. var convertResult = conversion.Convert("@/App_Data/sample.pdf", “converted\converted.jpg”, FileType.Jpg); - change to
var convertResult = conversion.Convert(“sample.pdf”, “converted\converted.jpg”, FileType.Jpg);

Best regards.