Problem while setting the Image Directory programatically

Last post 07-06-2005, 2:35 AM by rohitrawat. 2 replies.
Sort Posts: Previous Next
  •  07-05-2005, 11:56 AM 8371

    Problem while setting the Image Directory programatically

    I am having a problem while setting Image Directory for different Users programatically. It just makes the Cute Editor READONLY. I cannot click on any of the Button Icon. What could be wrong here?

    My Code is 
    If
    "Admin" Then
       
    Editor1.SecurityPolicyFile = "Admin.config"
        Editor2.SecurityPolicyFile = "Admin.config"
    ElseIf "User" Then
        Editor1.SecurityPolicyFile = "Default.config"
        Editor2.SecurityPolicyFile = "Default.config"
     
        Dim MyPath AsString
        MyPath = Server.MapPath("/Uploads/" & UserId & "/")
        SetUploadsFolder(MyPath)
    EndIf
     
    Private
    Sub SetUploadsFolder(ByVal folderString AsString)
        Dim phyfolder AsString
        phyfolder = folderString
        If (System.IO.Directory.Exists(folderString)) Then
            '--Do something here
        Else
           System.IO.Directory.CreateDirectory(folderString)
        EndIf

        Editor1.Setting("security:ImageGalleryPath") = folderString
        Editor1.Setting("security:FlashGalleryPath") = folderString
        Editor1.Setting("security:TemplateGalleryPath") = folderString

       Editor2.Setting("security:ImageGalleryPath") = folderString
       Editor2.Setting("security:FlashGalleryPath") = folderString
       Editor2.Setting("security:TemplateGalleryPath") = folderString


    End
    Sub
    Thanks in advance.
  •  07-05-2005, 4:47 PM 8376 in reply to 8371

    Re: Problem while setting the Image Directory programatically

    rohitrawat,
     
    You must miss some code here.
     
    This is an example showing how to do that. You can modify it to meet your own requirements.
     
    <script runat="server"> Public Sub Page_Load(sender As object, e As System.EventArgs) If Not Page.IsPostBack Then Editor1.SecurityPolicyFile = "default.config" SetUploadsFolder("~/Uploads/Member/") Editor1.ReadOnly = false End If End Sub public Sub security_Changed(sender As object, e As System.EventArgs) Dim temp As String = "" Select Case RadioList.SelectedItem.Value case "Administrators": Editor1.SecurityPolicyFile = "Admin.config" SetUploadsFolder("~/Uploads/") case "Members": Editor1.SecurityPolicyFile = "default.config" SetUploadsFolder("~/Uploads/Member/") case "Guest": Editor1.SecurityPolicyFile = "Guest.config" SetUploadsFolder("~/Uploads/Guest/") 'case "Banned": ' Editor1.ReadOnly = true case "John": Editor1.SecurityPolicyFile = "Admin.config" SetUploadsFolder("~/Uploads/Users/John/") case "Mary": Editor1.SecurityPolicyFile = "default.config" SetUploadsFolder("~/Uploads/Users/Mary/") case "Tim": Editor1.SecurityPolicyFile = "default.config" SetUploadsFolder("~/Uploads/Users/Tim/") End Select Literal1.Text = ShowSecuritySetting() End Sub Function ShowSecuritySetting() As String Dim temp As String = "" temp = temp & "Policy file: "+ Editor1.SecurityPolicyFile temp = temp & "<br>" temp = temp & "ImageGalleryPath: "+ Editor1.Setting("security:ImageGalleryPath") temp = temp & "<br>" temp = temp & "FilesGallaryPath: "+ Editor1.Setting("security:FilesGallaryPath") return temp End Function Sub SetUploadsFolder(ByVal folder As String) Dim phyfolder As String = Server.MapPath(folder) 'see security.config Editor1.Setting("security:ImageGalleryPath")=folder Editor1.Setting("security:MediaGalleryPath")=folder Editor1.Setting("security:FlashGalleryPath")=folder Editor1.Setting("security:FilesGallaryPath")=folder End Sub </script>

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  07-06-2005, 2:35 AM 8390 in reply to 8376

    Re: Problem while setting the Image Directory programatically

    Thanks Adam for the quick post. It did helped me resolving my problem as to READONLY. Though there was one more thing that I was not adhering to that is to change
     
    MyPath = Server.MapPath("/Uploads/" & UserId & "/")
     
    to
     
    MyPath = "~/Uploads/" & UserId & "/"

    It is now working smoothly as expected.
    Thanks for your help.

    Rohit
View as RSS news feed in XML