We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

FileExplorer problem (path error)

When I run my app I get a message error (pop-up): "Not Found"

I try modify the path to a local folder but it does not work too

This is my code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@using System.Web.Optimization
@using Syncfusion.MVC.EJ
@using Syncfusion.JavaScript;
@{
    ViewData["Title"] = "FileExplorer";
}
<link rel="stylesheet" rel='nofollow' href="http://cdn.syncfusion.com/14.3.0.49/js/web/flat-azure/ej.web.all.min.css" />
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"></script>
@Scripts.Render("~/Scripts/ej/ej.web.all.min.js")
<!-- Essential Studio for JavaScript theme reference -->
<link rel="stylesheet" rel='nofollow' href="http://cdn.syncfusion.com/14.3.0.49/js/web/flat-azure/ej.web.all.min.css" />
<!-- Essential Studio for JavaScript script references -->
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://cdn.syncfusion.com/js/assets/external/jquery.easing.1.3.min.js"></script>
<script src="http://cdn.syncfusion.com/js/assets/external/jsrender.min.js"></script>
<script src="http://cdn.syncfusion.com/14.3.0.49/js/web/ej.web.all.min.js"></script>
<div class="col-md-12">
    <div class="box box-primary">
        @(Html.EJ().FileExplorer("fileExplorer")
               .FileTypes("*.png, *.gif, *.jpg, *.jpeg, *.docx, *.pdf").Layout(LayoutType.Tile)
               .Path("~/FileExplorerContent/")
               .AjaxAction(@Url.Content("FileExplorer/FileActionDefault"))
               .Width("100%")
               .IsResponsive(true)
               .MinWidth("350px"))
        </div>
</div>
@Html.EJ().ScriptManager()

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 public class FileExplorerController : Controller
    {
        // GET: FileExplorer
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult FileActionDefault(FileExplorerParams args)
        {
            FileExplorerOperations opeartion = new FileExplorerOperations();
            switch (args.ActionType)
            {
                case "Read":
                    return Json(opeartion.Read(args.Path, args.ExtensionsAllow));
                case "CreateFolder":
                    return Json(opeartion.CreateFolder(args.Path, args.Name));
                case "Paste":
                    return Json(opeartion.Paste(args.LocationFrom, args.LocationTo, args.Names, args.Action, args.CommonFiles));
                case "Remove":
                    return Json(opeartion.Remove(args.Names, args.Path));
                case "Rename":
                    return Json(opeartion.Rename(args.Path, args.Name, args.NewName, args.CommonFiles));
                case "GetDetails":
                    return Json(opeartion.GetDetails(args.Path, args.Names));
                case "Download":
                    opeartion.Download(args.Path, args.Names);
                    break;
                case "Upload":
                    opeartion.Upload(args.FileUpload, args.Path);
                    break;
                case "Search":
                    return Json(opeartion.Search(args.Path, args.ExtensionsAllow, args.SearchString, args.CaseSensitive));
            }
            return Json("");
        }
    }

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

14 Replies

BP Balamurugan P Syncfusion Team November 9, 2016 06:23 AM UTC

Hi Anis, 
Thanks for using Syncfusion products. 
 
We have analyzed the reported issue with your provided code blocks and we could found that, the path of the controller AJAX action handling functionality is not specified properly in the “AjaxAction” API of FileExplorer. To solve this problem, you have to use the “AjaxAction” API path as ‘@Url.Content("FileActionDefault")’ instead of using ‘@Url.Content("FileExplorer/FileActionDefault")’. Also once ensure that you have “FileExplorerContent” folder in proper location of your project. For your reference we have attached following image, please refer this. 
 
We have prepared a sample based on this and you can find the sample under the following link. 
 
Please let us know if you require any further assistance. 
 
Regards, 
Balamurugan 



AN Anis November 9, 2016 11:26 AM UTC

Thank you for helping, the sample project is work fine, but when I use the code in my project I get error (File Explorer is empty and I can not create a new folder or download file).
I didn't mention that I use serenity template and I call scripts files and stylesheet ref in same view of the FileExplorer not in _Layout.cshtm (this work with kanban view).


Attachment: Project_Files_4a320053.rar


BP Balamurugan P Syncfusion Team November 10, 2016 06:02 AM UTC

Hi Anis,  
 
Sorry for the inconvenience caused.  
 
We have analyzed the stated issue with your details and we could found that the qualified URL to an action method of “FileExplorer” was not generated properly with “URL.Content” and this problem occurs while navigating from any other page to Index page. To solve this problem, you have to use “Url.Action” instead of using “Url.content” in the “AjaxAction” API of FileExplorer, since it need fully qualified URL to action method of FileExplorer.  
  
 
@Url.Action("FileActionDefault") 
 
 
We have prepared a updated sample based on this and you can find the sample under the following link.  
 
 
As specified in previous response, please once ensure that you have “FileExplorerContent” folder in proper location of your project. For your reference we have attached following image, please refer this.  

Please let us know if you require any further assistance.  

Regards, 
Balamurugan P 



AN Anis November 10, 2016 02:48 PM UTC

Hello again,
This does not work, so I reproduce the error in the project below, can you please take a look.

project : FileExplorer
user: admin
passwd: serenity


AN Anis November 14, 2016 06:42 AM UTC

Hello, is there a solution for my problem or not?
I really need a solution as soon as possible.


BP Balamurugan P Syncfusion Team November 14, 2016 11:24 AM UTC

Hi Anis, 
 

Sorry for the inconvenience caused.   

We have analyzed the stated issue with your sample and we could found that you are using attribute routing in your ASP.NET MVC project. Due to this, while making AJAX post request to "FileActionDefault" action with some parameters, you are getting routing attribute in “FileExplorerParams” arguments instead of getting AJAX action request parameters. This is the reason for reported problem.

To solve this problem, please refer following code block, which helps to get the AJAX request parameters in the file action “FileActionDefault” controller part.

   var serializer = new
JavaScriptSerializer(); 

   FileExplorerOperations operation = new
FileExplorerOperations(); 

   var req = ControllerContext.HttpContext.Request;                 

   req.InputStream.Seek(0, SeekOrigin.Begin); 

   var jsonStringData = new
StreamReader(req.InputStream).ReadToEnd(); 

   FileExplorerParams args = new
FileExplorerParams();

   args = (FileExplorerParams)serializer.Deserialize(jsonStringData, typeof(FileExplorerParams));

Please find the modified sample under the following location.  

Sample: http://www.syncfusion.com/downloads/support/forum/127281/ze/File_Explorer.Web-1102198667  


Note: Modification was done in “FileExplorerController.cs” file of the attached project. 

Please let us know if you require any further assistance. 


Regards, 

Balamurugan 





AN Anis November 14, 2016 03:35 PM UTC

Thank you very much, it works, just I can not open the image files in the browser.
Now I want to know if it is possible to switch from any view to a specific folder in the file explorer.
Explanation:
- I want a notification system that displays notification in specific conditions (exp: a product out of stock) for some users , 
- when the user clicks  the notification, the browser must load the file explorer view, and navigate specifically to the folder related to the notification.

Exp : view 1 --------> notification click --------> view 2 (FileExplorer) + "~/FileExplorerContent/Products/product_12"

Regards


BP Balamurugan P Syncfusion Team November 15, 2016 09:41 AM UTC

Hi Anis,     
 
Query 1:  I cannot open the image files in the browser. 
We have checked the reported problem, and it occurs while loading with “http://localhost:57139/DocumentsManagement/FileExplorer/index” URL. You can avoid this issue by specifying the path as Path("/FileExplorerContent/"). Also ensure that you are not enabled “EnableThumbnailCompress” API. Still if you have this problem, please provide some additional information like browser  details. This would be helpful to us to serve you. 
 
Query 2: I want to know if it is possible to switch from any view to a specific folder in the file explorer. 
You can find the solution for this query in newly created 127421 forum. 
 
Please let us know if you require any further assistance. 

Regards, 



AN Anis November 15, 2016 02:00 PM UTC

Hello,
The solution (Path("/FileExplorerContent/") give me this error message: "System.IO.DirectoryNotFoundException, Could not find a part of the path 'C:\inetpub\wwwroot\FileExplorerContent'.", and I tested in Chrome v 54.0.2840.71 m (64-bit) and Internet Explorer 11.
Another question: how can I open pdf file from FileExplorer in the browser (pop-up windows or in new windows) ?


Regards, 



BP Balamurugan P Syncfusion Team November 16, 2016 07:24 AM UTC

Hi Anis,      
   
Query 1:  I cannot open the image files in the browser.    
  
We have analyzed the reported issue in our side and its working fine. Also, we suspect that the “FileExplorer” directory content path does not map properly, which is available in your project. This will be a reason for the reported issue. To solve this problem, please use “Url.Content()” method in the “System.Web.Mvc.UrlHelper” class that allows you to easily convert a virtual-root relative path to an application absolute path.   
   
Please refer following code block.   
   
        @(Html.EJ().FileExplorer("fileExplorer")   
               .FileTypes("*.png, *.gif, *.jpg, *.jpeg, *.docx, *.pdf")   
               .Layout(LayoutType.Tile)   
               .Path(@Url.Content("~/FileExplorerContent/"))   
               .AjaxAction(@Url.Action("FileActionDefault"))                  
               .Width("100%")   
               .IsResponsive(true)   
               .MinWidth("350px")   
        )   
  
  
Query 2:  how can I open pdf file from FileExplorer in the browser (pop-up windows or in new windows)   
At present, using our FileExplorer control, we can open image files only. We don’t have built-in support to open other type of files like (pdf, html, doc, etc...). Already we have logged “Unable to open files other than image types in FileExplorer” as feature request in our database and we will implement this feature in any of our upcoming releases. We will update you once if this feature has got implemented.   
 
For your convenience, we have prepared a workaround solution, we can achieve your requirement by using “create” and “beforeOpen” events of FileExplorer. Here “create” event, helps to enable the context menu item after creating “FileExplorer” control. And “beforeOpen” helps to customize your file open operation as per your requirement. Please refer following code example.    
   
Code example:   
@(Html.EJ().FileExplorer("fileExplorer")   
     .FileTypes("*.png, *.gif, *.jpg, *.jpeg, *.docx, *.pdf")   
     .Layout(LayoutType.Tile)   
     .Path(@Url.Content("~/FileExplorerContent/"))   
     .AjaxAction(@Url.Action("FileActionDefault"))                  
      .Width("100%")   
      .IsResponsive(true)   
      .MinWidth("350px")   
      .ClientSideEvents(eve=>eve.Create("onCreate").BeforeOpen("onBeforeOpen"))   
)   
<script type="text/javascript">   
    function onCreate(args) {   
        this._viewMenuObj.option({   
            open: function (args) {   
                this.enableItem("Open");   
            }   
        });   
    }   
    function onBeforeOpen(args) {   
        if (args.itemType == "File" && !(/\.(bmp|dib|jpg|jpeg|jpe|jfif|gif|tif|tiff|png|ico)$/i).test(this._selectedFile)) {   
            //you can get parent path using "args.model.selectedFolder"    
            //you can get selected file name using "args.model.selectedItems"    
            var file = args.model.selectedFolder.replace("~""..") + args.model.selectedItems[0];   
            window.open(file, args.model.selectedItems[0], '_blank''fullscreen=yes, menubar=yes, resizable=yes, titlebar=yes, toolbar=yes');   
            args.cancel = true;   
        }   
    }   
   
   
</script>   
  
   
We have prepared a sample based on this and you can find the sample under the following location:    
   
Please let us know if you require any further assistance.    
   
Regards,    
Balamurugan    



AN Anis November 16, 2016 11:12 AM UTC

Thank you very much for your help.


BP Balamurugan P Syncfusion Team November 17, 2016 04:26 AM UTC

Hi Anis, 
Most welcome. 
  
Regards, 
Balamurugan 



AN Anis November 23, 2016 04:00 PM UTC

Hello;
The "upload" function does not work, I found that there is a missing code
case "Upload":
                    opeartion.Upload(args.FileUpload, args.Path);

I add this code to the controller but the problem is still there.


BP Balamurugan P Syncfusion Team November 24, 2016 07:26 AM UTC

Hi Anis,  
We have checked your reported problem with our previously attached sample. In that sample, upload functionality was working fine. There is no necessary to include the following code in the controller part. 
 
case "Upload":
                    opeartion.Upload(args.FileUpload, args.Path);
 
 
In attached sample, we have performed “upload” operation in “GetAjaxData” method and not in “FileActionDefault”. We have made this correction, since you have used the attribute based routing in your application. 
 
Notes: In your application, you have used attribute based routing. Due to this reason, you can’t  get upload operation related arguments in “FileActionDefault” action handling method. So that, you are not able to include above code block in the controller part. In alternatively, we have performed the upload operation in  GetAjaxData” for your requirement. 



Please let us know if you require any further assistance.     

Regards, 
Balamurugan P 


Loader.
Live Chat Icon For mobile
Up arrow icon