|
Dear All
Please provide the solution as how to skip from the inner folder during "for each" loop and jump to the main folder.
R.Sasikumar
|
|
|
|
|
Well that is the third message you have posted and we still have no more idea of what your problem is. It is no good just dumping a load of code and saying "please help me". You need to be specific about what problem occurs in your code and exactly where it occurs. If you don't have that information then use your debugger or some logging techniques to isolate it.
|
|
|
|
|
"It's not working" is not a problem description. You haven't described, in detail, anything about what the code is doing compared to what you expect it to be doing. Without that, there's nothing anyone can do to help you.
|
|
|
|
|
OK i will keep it simple.
I have entered main folder say (D:\officecode) inside which so many subfolder 1101,1102.
'Main folder(say D:\officecode)
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
GetDestFolder(Subfolder)
ShowSubFolders Subfolder
Next
End Sub
'After entering the above function it will traverse inside the folders say D:\officecode\1101 and i creating folders inside this folder using the below function
'function to Create 2 new inner folders say 'lob/year
Sub GetDestFolder(pFolder)
If Not objFSO.FolderExists(FlName) Then
Set objFolder = objFSO.CreateFolder(FlName)
End If
FlName = pFolder.Path & "\" & lob & "\" & moyr
If Not objFSO.FolderExists(FlName) Then
Set objFolder = objFSO.CreateFolder(FlName)
End If
End Sub
'After executing this function again it will go to ShowSubFolders function and i recursively call it. But the code getting into the newly create folders "D:\officecode\1101\lob\year" and again creating new folder inside it ""D:\officecode\1101\lob\year\lob\year" but i want to jump to outer folder "D:\officecode" and start with next folder "D:\officecode\1102". Kindly help me to get out of the inner loop in between this recursively function and going back to main folder.
R.Sasikumar
|
|
|
|
|
I can't see all of the code, but it would appear that you're using "global" variables to hold the path strings. Don't. There is no need to use global variables for this stuff. use local variables and it should fix the problem.
|
|
|
|
|
Hello again,
unfortunately my problem (just below) looked like resolved, but something got completely twisted. Something seems to be really wrong in my Settings configuration, since I have the following effects:
- In my main form, I have a custom control, which (of course) is initialized in the form designer.
- A text field in it is supposed to open with a path retrieved from My.Settings, the UserSourcePath.
- When debugging I stop the code during initialization in the line "Private _userSourcPath As String = My.Settings.UserSourcePath" and check for the value
--> FUNNY: It' not the value that I have in the settings, but a value that I set at runtime when debugging before.
Everything else seems to work quite normal, e.g. the settings I made show in the projects properties as supposed to.
I have no idea where this alternative setting is stored i.e. from where it's retrieved. Searching the string with Ctrl-F doesn't give any results.
Could someone please give me any hints how to resolve this strange effect? Where can I search for the string that's actually used instead of my intended setting?
Thank you,
Mick
|
|
|
|
|
I'm making some assumptions here because your post isn't specific.
If the breakpoint is on that line, it hasn't executed the line yet. You have to step through that line to the next one to get it to execute.
Now, if your "custom control" is in another project and you're putting settings in that project, it's not going to work. Settings will always come from the application you're using the control in, not the controls own settings file.
|
|
|
|
|
Thank you, Dave. Sorry for not being specific enough.
The breakpoint is on that line, as you assume, but I should be able to see (hovering) the value of "My.Settings.UserSourcePath". This was the case before as well as it is in a new project. Hovering over it, I see the wrong path which must be stored somewhere...
The custom control is in the same project, just in a subdirectory named "Controls", and it's in the Namespace "Controls" as well. In the designer I assign the textfields value to "My.Settings.UserSourcePath" as well.
Do you have further hints what to examine?
EDIT / ADDITIONAL:
I just played around with manually changing the settings and then debugging. That makes it even more funny, since I found that some of the values actually do come from the manual settings (main settings file), all of them referenced through "My.Settings.xxx". So the problem doesn't seem to be Namespaces related - I hope the assumption is ok.
But how can I find out WHERE the variable "My.Settings.UserSourcePath" comes from, i.e. why I get my latest runtime entry instead of the actual setting????
modified 27-Nov-16 7:51am.
|
|
|
|
|
Sonhospa wrote: Do you have further hints what to examine? Download Notepad++, do a "find in all files". Set the file-extensions to look for to ".cs", and search for your string.
Your settings-file is a resource-file, and Visual Studio would generate some code for it; any settings-name should have a property. Search for it on the harddrive, and you'll find the location of your file.
You now also know why most of us roll their own configuration-files
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thank you, Eddy! In case you're still online: Does that method give different results than searching for the string in VS2010? Coz that's what I did already, searching for the String (the one that's not in the settings). I saw the code in the settings.designer file and in the settings.vb file, both hold the settings that I can see in the project properties, i.e. are correct. The string that appears (on hover) is the string that I entered at runtime (a different one for test purposes), and searching for it didn't bring any results.
p.s.: Are you sure searching for ".cs" makes sense in a VB project? I'm asking seriously, as my programming knowledge is limited.
|
|
|
|
|
Yes, the results will be different.
The results in Visual Studio will only search the files that are visible in your project. Notepad++ will search ALL of the files in the project folder.
|
|
|
|
|
Hi,
I followed your advice (Eddy) with notepad++, setting the filter to "*.*" and searching for "My.Settings.UserSource_Path", because in initialization it's "nothing" which isn't a searchable string. I only get results from 2 vb-files, not even the settings.settings and settings.designer files of which I know they have the string in them.
So this approach didn't help... Still can't find out why it's nothing instead of the project properties entry.
Thank you though,
Mick
|
|
|
|
|
Sonhospa wrote: Still can't find out why it's nothing instead of the project properties entry. It is probably using settings from another location, with default values.
Are you by any chance on a network where the users' home folders are mapped to a network drive?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello Eddy,
sorry for the late response, I didn't have access to programming stuff for a few days.
While my VS2010 projects are on the "E:" harddrive, the user's folders (pictures, videos etc) are mapped to "F:\Media" on the same computer (separate harddrive). No network connections.
I wonder what would cause such a twist... you seem to have an idea... Btw I'm under Win7-64bit.
|
|
|
|
|
|
Hello,
sorry again for the late response. With the help of your links (i.e. the articles) I was at least able to eliminate older/probably competing settings files and put most of the code into a new project which is running.
Thank you for the advice, Eddy!
I wish you a merry Christmas and a happy new year.
|
|
|
|
|
You're welcome. Merry Christmas and happy new year to you also
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello to everyone,
it might sound funny, but in a current project "suddenly" (i.e. I don't know what I exactly did) the references to "My.Settings" didn't work anymore. Instead, I had many errors saying that "Settings" isn't a property of "My".
What I did: I opened a completely new (winforms-) project and looked into the files having "My.Settings" (etc) in their text, and adapted my project files "app.config", "settings.settings" and "settings.designer" (manually inserting the properties) to the syntax and entries I saw in the new (sample) project.
First I thought it's ok: All the error messages disappeared. But when debugging, I can see that my settings references (e.g. "My.Settings.UserPath") only supply empty strings. This implies to me that the valid entries must be out of the valid scope (or something like that), i.e. I must have overlooked something... typos are checked.
Could one of you please advise me, where else I might look for errors or what else I could do?
Thank you very much in advance,
Mick
|
|
|
|
|
Go to PROJECT -> Properties on the VS menu. Or right click on the project in the Solution Explorer window and select Properties. You should then be able to navigate to the Settings section.
|
|
|
|
|
Thank you, Richard - but both methods work normal and I see the usual page with my user settings.
The problem occurs when "InitializeComponent" calls
Private _userSourcePath As String = My.Settings.UserSourcePath <--------------
Public Property UserSourcePath() As String
Get... which is called by , returns an empty string instead of the actual settings entry.
I think I must have made an error when manually editing the mentioned files. For example, I don't know where I would place the Namespace reference in "app.config" or in the settings files.
Any other idea?
|
|
|
|
|
Sonhospa wrote: Any other idea? Sorry, no. But I would certainly not recommend manually editing these files, as it is too easy to make a mistake that does not show up until you try running the code. I can only suggest you recreate your project and settings via Visual Studio.
|
|
|
|
|
Thank you though, Richard.
Finally I found the problem: The file "settings.designer.vb" had it's first part of the code (where the properties are defined) wrapped into "Namespace My"/"End Namespace". Obviously that's not right and lead to wrong references / empty string.
Now it works again !
Have a nice day,
Mick
|
|
|
|
|
In a vb.net 2010 application, I am trying to determine the best way to accomplish this goal.
Write now 1 letter is generated and sent to one guardian. However this application needs to be
changed so that the same exact letter can be send to different mailing addresses since each student may have more than one parent/guardian at different mailing addresses. So basically I want to generate more than one letter with the same wording. The only differences between the letters would be the mailingaddresses. I want the letters to be written to the same varchar(max) column in a sql server 2012 database. The letters will be in the same field since the data will be sent to a sql server reporting server where the letters will be generated one after each other.Right now the letters are written to the 'Dim _al As Letters = New Letters()' object. The only way I know to modify text data is to use a string or stringbuilder objects. I do not know yo modify data is other objects. Basically I want to use a string.replace logic to replace the addresses in the second letter. I also want to use
stringbuilder.append to place more than one letter following another to be placed in the osne varchar(max) field.
I know I can use the following code to convert a custom object to a string.
Dim _LetterStr As String = String.Empty
Dim _LetterStrbldr As StringBuilder = New StringBuilder
_LetterStr = _Letter.Letter.ToString()
However I do not know how to convert a string object back to a custom object.
Here is the original code of the application:
#Region "Protected Sub btnSubmitModifiedLetter_Click(ByVal sender As Object,
ByVal e As System.EventArgs) Handles btnSubmitModifiedLetter.Click"
Protected Sub btnSubmitModifiedLetter_Click(ByVal sender As Object, ByVal e
As System.EventArgs) Handles btnSubmitModifiedLetter.Click
Dim _al As Letters = New Letters()
Dim _infinteCampusText As String
Dim _Letter As Letter = New Letter()
Dim _startDate As DateTime = Now()
Dim _term As Integer = 0
_Letter.SchoolYear = _schoolyear
_Letter.Term = _term
_Letter.Milestone = ddlMilestone.SelectedValue
_Letter.SchoolNumber = Right("000" & ddlSchools.SelectedValue,3)
_Letter.Printed = "Y"
_Letter.Letter = reLetterEditor.Content
_Letter.StudentLink = Right("0000000" & txtStuLink.Text, 7)
_Letter.Language = txtLanguage.Text
_infinteCampusText = _al.BuildText(_Letter)
_al.InsertData(_Letter, _infinteText)
btnProcessSelections.Visible = False
gvLetters.DataSourceID = String.Empty
gvLetters.DataBind()
gvLetters.Visible = False
Response.Redirect("letter.aspx?schoolyear=" +
_Letter.SchoolYear.ToString() + "&schoolnum=" +
_Letter.SchoolNumber.ToString() + "&term=" +
_Letter.Term.ToString() + "&milestonecode=" +
_Letter.Milestone.ToString() + "&startdate=" + _startDate.ToString() +
"&enddate=" + DateAdd(DateInterval.Day, 1, Today()).ToString() +
"&language=ALL&studentlink=ALL")
End Sub
#End Region
Thus can you show me the code to convert a string object to a custom object and/or show me code on how to accomplish my goal?
|
|
|
|
|
Why would you need to do such a conversion? All you need is a template that contains the main text of your letter, a _Letter object that contains the different properties (name, address etc), and a subroutine that formats the data into its printed form.
|
|
|
|
|
Would you show me an example of the code you are referring to? How should I convert a string object to a custom .net object?
|
|
|
|