Solved

BC30456: 'Exists' is not a member of 'Directory'.

Posted on 2016-08-22
1
70 Views
Last Modified: 2016-08-23
I am working on a web application with Visual Studios using VB as my language. As I was building the site I would occasionally copy and paste from an existing webform tto create a new web form. I didn't realize that I also had to change the inherits statement in the declaration and the Partial Class name. It still worked absolutely fine in my development environment. When I published to the hosted server it of course cause problems. Since I have gone back and manually changed the inherits statement and Partial Class names to be the same in all instances but I am now getting a   "BC30456: 'Exists' is not a member of 'Directory'." error at runtime. When I try to compile the ste I am getting

Severity	Code	Description	Project	File	Line	Suppression State
Error		'Exists' is not a member of 'Directory'.	CommunityCrier	C:\Users\ohwoo\AppData\Local\Temp\WebSitePublish\CommunityCrier--1942723409\obj\Debug\AspnetCompileMerge\Source\LoggedIn\ProfileEdit.aspx.vb	308	
Error		'CreateDirectory' is not a member of 'Directory'.	CommunityCrier	C:\Users\ohwoo\AppData\Local\Temp\WebSitePublish\CommunityCrier--1942723409\obj\Debug\AspnetCompileMerge\Source\LoggedIn\ProfileEdit.aspx.vb	310	

Open in new window


The declarations from my .aspx page are:
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPagers/FrontEnd.master" AutoEventWireup="false" CodeFile="ProfileEdit.aspx.vb" Inherits="LoggedIn_ProfileEdit" %>

Open in new window


The imports and  partial class are:
Imports System.Data
Imports CommunityCrierModel
Imports System.IO
Imports System.IO.Directory
Imports System.Web.UI.Page

Partial Class LoggedIn_ProfileEdit
    Inherits System.Web.UI.Page

Open in new window


The actual code is:
    Private Function SaveProfileImage() As String
        Dim strFilePath As String
        Dim myFilePath As String
        Dim strImageLocation As String

        'define file path
        strFilePath = "~/Images/PersonalImages/" & User.Identity.Name
        myFilePath = Server.MapPath(strFilePath)

        'check to see if file exists
        If Not Directory.Exists(myFilePath) Then
            'create direcory
            Directory.CreateDirectory(myFilePath)
        End If

        'define and get variables for saving uploaded image
        Dim strVirtualFolder As String = "~/Images/PersonalImages/" & User.Identity.Name & "/"
        Dim strPhysicalFolder As String = Server.MapPath(strVirtualFolder)
        Dim strFileName As String = Guid.NewGuid().ToString()
        Dim strExtension As String = Path.GetExtension(fulUserImage.FileName)

        strImageLocation = strVirtualFolder + strFileName + strExtension
        fulUserImage.SaveAs(System.IO.Path.Combine(strPhysicalFolder, strFileName + strExtension))

        Return strImageLocation
    End Function

Open in new window


I really want to be able to create appropriate directories on the fly for each user and not have potentially thousands of images from hundreds of different users store in the same file.

Let me know if you need any other information.

Any help or direction would be greatly appreciated.

Thanks,
Doug
0
Comment
Question by:OhioWoodWright
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 7

Accepted Solution

by:
Scobber earned 500 total points
ID: 41766105
instead of using directory.exists try io.directory.exists
the reason being it appears its using a different namespace.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question