Add an already existing directory to a directory in Solution Explorer - visual-studio-2012

I want to add an already existing directory to a directory in Solution Explorer, but whenever I right-click on the directory and select Add => Existing Item, I can only add individual files, but not directories.
How do I add an already existing directory to a directory inside a Project inside Solution Explorer?

Click the 'Show all files' button at the top of the Solution Explorer and right click the folder desired and select 'include in project'.

Drag and drop the folder from Windows Explorer onto your Visual Studio solution window :)
Source here
or simply copy & paste into solution explorer.

VS 2012 seems to distinguish between 'Solution Folders', which are only folders containing either other solution folders, or containing project folders. The drag-and-drop works (with my settings) only for the project folders, and no for the solution folders.
If I add a new solution folder, nothing happens on the machine. If I drag-and-drop a machine folder to the main Solution, it refuses to accept it. If I drag-and-drop the folder to a Solution Folder, I get an error message saying this cannot be done.

Some other answers are missing an important point: if the folder is not in a project in the solution it is impossible to add the folder
This is the solution:
1) Add a new folder to the sln - it does not care that the folder already exists on the disk because this a virtual folder in the sln
2) Add the file to the folder using "add existing files"

When dealing with a solution level folder that has been removed for some reason, and now needs to be added back, open the .sln file in a text editor like notepad++.
Find your "FolderName" in the section that looks like this...
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NewFolder1", "NewFolder1", "{73ED84FC-F250-4CCC-B267-34CEB67F2883}"
EndProject
Delete from "Project" to "EndProject" ONLY for the specific Project/Folder you're having trouble with.
You may get a message in VS2012 that says your solution has been modified by an external source. Choose the option to "Discard" your changes for the external changes. Lastly, add your solution level folder, and add your project(s) to that folder as existing items, drag/drop them, or copy and paste them, according to your preference.

For those who had a hunch it could be done but weren't able to do it, NOTE: Drag Folder or Files ONTO the name of the Project Name in Solution Explorer in the least

Expand the "Project" item in the menu bar and select "Show All Files". Then locate the folder you wish to add in the Solution Explorer (folders that are not currently included will be light grey with a dotted outline instead of the usual solid icon) right click the desired folder and select "Include in project"
Once finished select "Show All Files" from the Project menu again to return to the regular view.
(This is very similar to Radenko Zec's answer, but does not require the "Show All Files" button to already be present in a toolbar. I would just leave this as a response to his answer, but I don't currently have the reputation to leave comments.)

Related

.gradle\caches\6.1.1\file-changes\last-build.bin (Access is denied)

I've tried to delete .gradle folder or delete last-build.bin file, but it isn't work. Could everyone have the solution to this problem ? thank you...
One simple solution is
I believe that another solution for that could as much be related to hidden folders. If that is the problem:
Check if your User folder is not hidden C:/User..
On the tab menu, select View.
On your far right there will be Options, select.
It will display Folder Options with the following tabs: General, View and Search. Here again, be sure to select View.
Navigate to Hidden files and folders.
And under that folder, just select Show hidden files and folders radio button.
Should that not do the trick, then move on to check if ALL the folders related to that path all the way to Caches are not hidden. The culprit here, should be that the: .gradle\caches is hidden.
Therefore, tap on the folder and unhide it activating the Caches folder(don't open it - just select it) and clicking View once again. Just next to Options on your far right, there should be Unhide selected items on the left. Of course, Unhide them and wait until the attributes are well applied. Now you are good to go, you should not experience that problem any longer.
I think that should do the trick if by any means your folder got hidden. Be sure to do that first, before following any of those technical steps. If your folders are hidden, Android Studio or Intelli j for that matters, cannot access the path in question.
Goto File -> Invalidate caches / Restart
Shutdown Android Studio
Rename/remove .gradle folder in the user home directory
Restart Android Studio (It will download gradle metadata and data)
Gradle build succeed
Rebuild project. Done.
reference

Android studio directory creation

I am working on a project in Android Studio. Whenever I try to create a new resource directory under the default /res directory it doesn't appear on the project scope, but it does appear on the packages scope. How can that be? Also, whenever I try to create a layout file (XML) in the directory I create, the file that is created is not placed under the selected and desired directory.
Hope it makes sense with an example.I got these:
/app/res/layout
/app/res/layout-land
/app/res/layout-large
If I create a file in /layout-land, Android IDE places it in the /layout directory.
Any suggestions appreciated.
When you have created the the layout-land folder it is not shown in the project view, however if you right click on the res folder and choose to show in project explorer you can see the folder has been created there as you have pointed out.
When you add an XML file to this layout-land folder (copy and paste the XML file in the existing layout folder), the XML file should become visible in the res/layout folder in the project view with (land) after it to indicate it is the landscape XML file.
Finally after a lot of testing trying every button in Android Studio I Knew how to do it.
In my case I wanted to create a folder layout-port and inside that folder two xml files: activity_main.xml and detail_activity.xml but every time I tried to add a xml file that was created in layout folder.
To create in layout_port folder I had to right click in layout-port then choose New -> Layout Resources File like the image below
Please see this insctruction for different layout orientation:
You can switch between layouts in the designer as you can see on the pictures.

How do I permanently exclude the bin and obj folders from TFS 2012 checkin?

I mucked around with TFS settings and I accidentally included the bin and obj folders for TFS 2012 checkin, and even checked them in already. I don't want this because these files change often and aren't meant for inclusion.
I've checked What happened to "Exclude from Source Control" in VS2012. The accepted answer doesn't work because the bin & obj folders and the DLLs inside those folders don't appear in the "Promote Candidate Changes" list, even after excluding them. The second most popular answer also doesn't work permanently. I press yes to all and it removes them from the included changes list, but when I do any action involving rebuilding, they're added to include list again.
I'm looking for a permanent solution which will permanently exclude these folders and the files inside from checkin, and if possible also removes them from the TFS server.
TFS 2012 has the option to drop a .tfIgnore file in your workspace.
Visual studio has a UI to create the file for you:
While you can manually create a .tfignore text file using the above rules, you can also automatically generate one when the Pending Changes page has detected a change.
To automatically generate a .tfignore file
In the Pending Changes page, in the Excluded Changes section, choose the Detected changes link.
The Promote Candidate Changes dialogue box appears.
Select a file, open its context menu, and choose Ignore this local item, Ignore by extension, or Ignore by file name.
Choose OK or Cancel to close the Promote Candidate Changes dialog box.
A .tfignore file appears in the Included Changes section of the Pending Changes page. You can open this file and modify it to meet your needs.
The .tfignore file is automatically added as an included pending change so that the rules you have created will apply to each team member who gets the file.
Or create it from the command line using echo . > .tfIgnore and then open it using notepad.
Another trick is to name the file .tfIgnore. in explorer and save it. You'll probably be prompted if you want to change the extension, the answer, in this case, is: yes.
For Excluding Bin folders ,Tick "Show Solution Changes" Under View options in "Included Changes"
I called in the help of our TFS admin.
We couldn't make a .tfignore file, but what did work was the following:
Check in both folders in TFS;
Delete the dlls and pdbs which are unique to the project from the source control explorer and check in this change.
Rebuild the project locally, try to check in and confirm that there are no pending changes.
the dependent assemblies remain in TFS, but since these rarely change, this isn't a big issue.

How to create new res folder in Android Studio

I want to add localized strings for my android app. Therefore I need a values-xx folder in my Res folder.
The original values folder has a blue dot, so I tried creating a new Package, but a package can't contain a hyphen so this must be wrong. Instead I tried right-clicking res and choosing New -> Android resource directory, but this time nothing happens. No dialog or reaction of any sort as I can see.
How do I create a values-xx folder?
Edit: I can create the folder from file explorer and it all works good. It is just irritating to not be able to do it from inside Android Studio.
Edit2: This bug is fixed in newer versions of Android Studio.
When you are in the Android view (rather than Project or Packages) in Android studio, you just need to right click the "values" directory and choose New > "Values resource file".
That gives you a chose of different resources you can add. For example, if you want to add a different language to your app you can choose the Language option and press the ">>" button. If you want Swahili then select that from the list, type "strings" for the file name, and press OK.
Android Studio will automatically create a values-sw directory with the new strings.xml file in it. And in your Android file view you conveniently see both strings files together.
And it is a similar process for adding other types of resources (see my other example). You no longer have to manually add the directories (but you can do that too by right clicking the res directory and choosing New > Android resource directory).
I had the same problem, what I did was create a values-xx folder inside the main directory (main>>right click>>new>>directory) and then moved that folder to res/ directory.
It's not beautiful but it is a workaround to create a folder with Android studio.
This bug is fixed in newer versions of Android Studio.
The values-xx folder we created is not showing, but when we create a file its asking
=>I have created values-21 folder and then tried with creating an xml and it asks for choosing a directory
=>I have updated to Android 1.02
Check the values-21
Lets assume i Want to create a folder named "Daylight" under res.
Step 1:
Right click on res.
Step 2:
Then go to New.
Step 3:
Then go to Folder.
Step 4:
Then go to Res Folder Option and select.
A window will be open.
Step 5:
At that window check the unchecked box "Change Folder Location"
and as assumed we have to create folder "Daylight"
Step 6:
SO name the newly created folder as daylight, in this format. src/main/res/Daylight
Step 7:
Then, Finally Click finish.
If you have already created a new directory but just don't see it in the Project Tools window. Do this
Click on Project Tools window >> Android(Drop Down) >> Click Project.
Now you'll see all your Directories in res. See the picture:
Its very simple. I too had trouble initially.
Lets break it stepwise:-
1) Open your project
2) Right click the res folder
3) Choose New
4) Chose Directory
5) Name the directory.
Thats it!! It works for a fresh project everytime!
For those finding this answer when trying to add a new res folder to a library.
Right-click java/kotlin folder > New > Folder > Res Folder

What happened to "Exclude from Source Control" in VS2012

I want to exclude some of the files in code folders from TFS 2012 source control.
Before VS2012 this was done by the "Exclude from source control" command available in "Source Control Explorer"s right-click menu. But in VS2012 I can not find it.
Does anybody know where it is ?
(I am using a "Local" workspace by the way.)
When you click on "Detected Changes" in the Team Explorer pane, "Promote Candidate Changes" window opens. This window allows you to select among detected changes and promote them to a source controlled item.
In this "Promote Candidate Changes" window, you select a file (or multi select files with Shift), right-click on it and a context menu pops up which contains an "ignore this local item" option. If you you click on it, selected files are excluded from source control.
Visual Studio adds a file named ".tfignore" to the source control mapping root, which contains names of all files to be ignored by source control. (Previous TFS versions did not produce this file but they were all server workspaces. Since this is a "Local" workspace, filenames to be ignores need to be kept in the workspace)
I have the real solution.
In the "team explorer" pane, in the "pending changes" tab, right click a new file you don't want in source control, and click "undo".
It will leave the file in the project, and exclude it from TFS. In the project window, the file will never have a "lock" icon on the left of its name.
This is the easiest solution:
1. Select the file(s) in Solution Explorer
2. Go to File -> Source Control -> Advanced
and here it is
Keep in mind:
If you right click a file in Solution Explorer you only find "the most important options" not all :)
In VS2013 this is back but has been moved to the file menu: -
Select the file in the Solution Explorer
File > Source Control > Advanced > Exclude xxx.xxx from Source Control
I know that this is slightly off topic but thought it may help someone.
I have Visual Studio 2017 Enterprise, and the option to exclude does not exist under File->Source Control. My solution to this problem was to open the Source Control Explorer, and remove the item I wanted to exclude.
It's in the Pending Changes pane separated to Excluded Changes and Included Changes sections. It allows filtering and excluding or promoting items between sections.
!

Resources