none
Error when website is deployed to cloud: Could not find a part of the path 'F:\sitesroot\0\MyFolder\TextDoc.FIL'.

    Question

  • Hi,

    Recently I installed the upgraded version of Windows Azure Tools to my computer to version 1.6 (Nov 2011 version). .

    Since then, I am not able to access the files in folders on our website hosted on cloud.

    I get an error saying "Could not find a part of the path 'F:\sitesroot\0\MyFolder\TextDoc.FIL' "

    What I am doing here is that I am reading the contents of this TextDoc.FIL and using it for processing in my program.

    At first I was having this file in the App_Data folder. Then after getting this error, I thought there may be some sort of security issue and tried to read this file by placing it in another folder called "MyFolder". But the error still persists.

    Please help me to solve this.

     

    Sandeep

    Monday, January 02, 2012 12:01 PM

All replies

  • Hi,

    Recently I installed the upgraded version of Windows Azure Tools to my computer to version 1.6 (Nov 2011 version). .

    Since then, I am not able to access the files in folders on our website hosted on cloud.

    I get an error saying "Could not find a part of the path 'F:\sitesroot\0\MyFolder\TextDoc.FIL' "

    What I am doing here is that I am reading the contents of this TextDoc.FIL and using it for processing in my program.

    At first I was having this file in the App_Data folder. Then after getting this error, I thought there may be some sort of security issue and tried to read this file by placing it in another folder called "MyFolder". But the error still persists.

    Please help me to solve this.

     

    Sandeep


    Hi,

    For your description, I’d like to suggest you to share some code snippets to show where the exceptions throw, it seems that you package this .fIl file in azure application and deploy it on Management Portal, you can use Remote Desktop to connect the VM machine of azure platform, and make sure your file exist, then please also check your file path is correct.

    Another noteworthy point is if you have 2 or more instances in azure environment, the disk will not be shared by default, unless you set an internal endpoint in application, in other words, if you modify the file path in one instances, maybe the another instance will throw this exception.

    So please check the your application and if you still cannot solve your issue, please inform me.

    Hope it can help you.


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework
    Tuesday, January 03, 2012 5:14 AM
    Moderator
  • Hi all,

    I am still facing the same problem. I have confirmed the existence of the file also but still I am getting the error.

    I have a file called DBCredentials.FIL from which i take the server name, DB name, user id and password.

    Can you please let me know what can be cause of the error. When I run the project in the local machine, it works fine.

    But when I publish the project, it does not work. I get the error

    "Could not find a part of the path 'F:\sitesroot\0\App_Data\DBCredentials.FIL'."

    Please help.

    Regards

    Sandeep


    • Edited by MBytes Saturday, April 07, 2012 3:18 AM
    Friday, April 06, 2012 10:34 AM
  • Hi all,

    The code snippet is as shown below. I have an aspx page which is right below this line, where an object is created to establish connection to database.

    ---------------------------------------------------------------------------------------------------------------------------

    Public Class TestDB
        Inherits System.Web.UI.Page

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Try
                Dim objDB As GetDBConn = Nothing
                Dim strSQL As String = ""

                objDB = New GetDBConn
                strSQL = "SELECT TOP 1 Login FROM LoginTable"
                Label1.Text = CStr(objDB.GetScalar(strSQL))
            Catch ex As Exception
                Label1.Text = ex.Message
            End Try
        End Sub

    End Class

    ---------------------------------------------------------------------------------------------------------------------------

    The code given below is the class through which database connection is established.

    ---------------------------------------------------------------------------------------------------------------------------

    Public Class GetDBConn

    Dim mConn As SqlConnection = Nothing
    Dim mCmd As SqlCommand = Nothing
    Dim  mStrConn as String = ""

     Sub New(Optional ByVal pFileName As String = "DBCredentials.FIL")
      Try
       Dim sr As New IO.StreamReader(HttpContext.Current.Server.MapPath("~") & "\App_Data\" & pFileName)
       Dim i As Integer, buf As String, buf2 As String
       Dim mServerName As String = ""
       Dim mDBName As String = ""
       Dim mUser As String = ""
       Dim mPW As String = ""
       Dim mStrConn As String = ""

       While sr.EndOfStream = False
        buf = sr.ReadLine
        buf = DeEncrypt(buf)
        i = InStr(buf, "=")
        If i >= 1 Then
         buf2 = UCase(Trim(Left(buf, i - 1)))
         If buf2 = "SERVER" Then mServerName = Trim(Mid(buf, i + 1))
         If buf2 = "DB" Then mDBName = Trim(Mid(buf, i + 1))
         If buf2 = "LOGIN" Then mUser = Trim(Mid(buf, i + 1))
         If buf2 = "PWD" Then mPW = Trim(Mid(buf, i + 1))
        End If
       End While
       sr.Close()
       mStrConn = "Data Source=" & mServerName & "; Initial Catalog=" & mDBName & "; User id=" & mUser & ";Password=" & mPW
       If mConn Is Nothing Then
        mConn = New System.Data.SqlClient.SqlConnection(mStrConn)
        mConn.Open()
        mCmd = New SqlCommand
        mCmd.Connection = mConn
       End If
      Catch ex As Exception
       Throw New System.Exception(ex.Message)
      End Try
     End Sub

     Public Overloads Function GetScalar(ByVal strSQL As String) As Object
      Try
       mCmd.CommandText = strSQL
       mCmd.Connection = mConn
       Return mCmd.ExecuteScalar()
      Catch ex As Exception
       Throw New System.Exception(ex.Message)
       Return Nothing
      Finally
      End Try
      Return Nothing
     End Function

    End Class

    ---------------------------------------------------------------------------------------------------------------------------

    Can you please help me with this.

    The project works fine in my local system. But when I publish and host in on Azure, it gives an error saying 

    "Could not find a part of the path 'E:\sitesroot\0\App_Data\DBCredentials.FIL'. "

    Regards

    Sandeep



    • Edited by MBytes Saturday, April 07, 2012 3:56 AM
    Saturday, April 07, 2012 3:54 AM
  • Try to not store your file locally (inside VM's local storage) as it's considered non-volatile. Apart from that, the access is also limited.

    Unless it's only for temporary purpose, you can use Local Resource Storage.

    The solution is try to host your file to persistence storage such as Azure Storage / SQL Azure.


    Regards, Wely Lau http://wely-lau.net (Wordpress on Windows Azure)

    Wednesday, April 11, 2012 1:47 AM
  • Though you can store this file in blob or Azure storage, it is always a good practice to keep such configuration in ServiceConfiguration file.

    Best Regards

    Madhukar

    Thursday, April 12, 2012 8:09 AM