Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

It is possible that I'm missing something very obvious but now I can not see now. I have the reference to System.Windows.Forms and I have the next using classes:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;

using System.Windows.Forms;
using System.Windows.Forms.FolderBrowserDialog;

But the compiler always give to me the next error:

error CS0138: A using namespace directive can only be applied to namespaces; 'System.Windows.Forms.FolderBrowserDialog' is a type not a namespace

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
2.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

You cannot do

using System.Windows.Forms.FolderBrowserDialog;

as it is a type and not a namespace. The namespace it belongs to is System.Windows.Forms. Remove this line and if you want to instantiate a FolderBrowserDialog and just make sure you have the line

using System.Windows.Forms;

and make a FolderBrowserDialog like so:

var fbd = new FolderBrowserDialog();

All this is in contrast to Java, where you import types not use namespaces, which is where you may be going wrong - in Java you would do something like:

import System.Windows.Forms.FolderBrowserDialog;

and then be able to use it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to 16892 Developer Community-Open, Learning and Share
...