{"id":6629,"date":"2014-04-20T13:57:54","date_gmt":"2014-04-20T13:57:54","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/20\/c-wcf-file-and-folder-browser-collection-of-common-programming-errors\/"},"modified":"2014-04-20T13:57:54","modified_gmt":"2014-04-20T13:57:54","slug":"c-wcf-file-and-folder-browser-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/20\/c-wcf-file-and-folder-browser-collection-of-common-programming-errors\/","title":{"rendered":"c# wcf file and folder browser-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8348bcf40f55bc5818651824369caff1?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSoner G\u00f6n\u00fcl<\/p>\n<p>I have a windows service that host a wcf service to allow remot file and folder browsing. The windows service runs under the local system account.<\/p>\n<p>When browsing the <code>c:\\<\/code> drive the service reports over 2800 files in that folder. i have single stepped through the code and it does indeed report &gt;2800 files.<\/p>\n<p>How can this be correct?<\/p>\n<p><strong>C# Code<\/strong><\/p>\n<pre><code>   \/\/Files Manager\n\npublic ReturnClass FindSubFiles(String Folder_To_Search, String User, String SessionId)\n{\n    ReturnClass myReturnClass = new ReturnClass(-1, String.Empty, String.Empty, null, null, null, null);\n    try\n    {\n        Logging.Write_To_Log_File(\"Entry\", MethodBase.GetCurrentMethod().Name, \"\", \"\", \"\", \"\", User, SessionId, 1);\n        string[] filePaths = Directory.GetFiles(Folder_To_Search);\n        int count = 0;\n        foreach (string Folder in filePaths)\n        {\n            filePaths[count] = Path.GetFileName(filePaths[count]);\n\n            count++;\n        }\n        myReturnClass.ErrorCode = 1;\n        myReturnClass.FilePaths = filePaths;\n        Logging.Write_To_Log_File(\"Exit\", MethodBase.GetCurrentMethod().Name, \"\", \"\", \"\", \"\", User, SessionId, 1);\n        return myReturnClass;\n    }\n    catch (Exception ex) \n    {\n        Logging.Write_To_Log_File(\"Error\", MethodBase.GetCurrentMethod().Name, \"\", \"\", ex.ToString(), \"\", User, SessionId, 2);\n        myReturnClass.ErrorCode = -1;\n        myReturnClass.ErrorMessage = ex.ToString();\n        return myReturnClass;\n    }\n}\n<\/code><\/pre>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/cg2Q3.jpg?s=32&amp;g=1\" \/><br \/>\nNoctis<\/p>\n<p>the path i was passing in was c: what i should be passing in is c:\\\\<\/p>\n<p><strong>C# Code<\/strong><\/p>\n<pre><code>public ReturnClass FindSubFiles(String Folder_To_Search , \n                                String User, String SessionId )\n{\n    ReturnClass myReturnClass = new ReturnClass(-1, String.Empty, String.Empty, \n                                               null, null, null, null);\n    try\n    {\n        Logging.Write_To_Log_File(\"Entry\", MethodBase.GetCurrentMethod().Name, \n                                  \"\", \"\", \"\", \"\", User, SessionId, 1);\n        string[] filePaths = Directory.GetFiles(Folder_To_Search + \"\\\\\");\n        int count = 0;\n        foreach (string Folder in filePaths)\n        {\n            filePaths[count] = Path.GetFileName(filePaths[count]);\n\n            count++;\n        }\n        myReturnClass.ErrorCode = 1;\n        myReturnClass.FilePaths = filePaths;\n        Logging.Write_To_Log_File(\"Exit\", MethodBase.GetCurrentMethod().Name, \n                                  \"\", \"\", \"\", \"\", User, SessionId, 1);\n        return myReturnClass;\n    }\n    catch (Exception ex) \n    {\n        Logging.Write_To_Log_File(\"Error\", MethodBase.GetCurrentMethod().Name, \n                                  \"\", \"\", ex.ToString(), \"\", User, SessionId, 2);\n        myReturnClass.ErrorCode = -1;\n        myReturnClass.ErrorMessage = ex.ToString();\n        return myReturnClass;\n    }\n}\n<\/code><\/pre>\n<p>thanks Damo<\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Soner G\u00f6n\u00fcl I have a windows service that host a wcf service to allow remot file and folder browsing. The windows service runs under the local system account. When browsing the c:\\ drive the service reports over 2800 files in that folder. i have single stepped through the code and it does indeed report &gt;2800 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6629","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6629"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6629\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}