none
Question about 3.1 exercise RRS feed

  • Question

  • EDIT: I didn't know there was an answer key, sorry


    ok so at the end of curriculum 3.1 there is an exercise, so i got this far and now im stuck:

    TextWindow.WriteLine("What would you like to name the new directory? ")

    newdirectory = "C:\Program Files (x86)\temp\" + TextWindow.Read()
    File.CreateDirectory(newdirectory)
    TextWindow.WriteLine("Your new directory is located in: " + newdirectory)

    newfile = Network.DownloadFile("C:\Program Files (x86)\temp\TempSubdirectory\my.txt")
    TextWindow.WriteLine("Directory of your downloaded file: " + newfile)

    File.CopyFile(newfile, newdirectory)

    gottenfile = File.GetFiles(newdirectory)
    TextWindow.WriteLine("Your directory of the copied file: " + gottenfile)

    TextWindow.WriteLine(File.ReadContents(gottenfile))

    the part i am stuck on is why doesnt it read the contents of the new file from the new directory? i know i could just write

    TextWindow.WriteLine(File.ReadContents(newfile))

    but i want to be able to do stuff with the new file that was copied into the new directory.

    im really confused, thanks for your patience

    • Edited by FatRat27 Saturday, December 14, 2013 5:55 PM
    Saturday, December 14, 2013 5:32 PM

Answers

  • Probably because File.GetFiles returns and array of files, so the first file would be gottenfile[1], assuming only one file here.

    I would also not recommend putting files and directories in C:\Program Files (x86) since this requires elevated permissions and may not work, or if you make any kind of mistake you could seriously damage your PC by altering files here.

    Saturday, December 14, 2013 7:21 PM
    Moderator
  • A post from another 3.1 exercise user. Chock-full of tips:  :D

    small-basic-technet-tutorial-lesson-31


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Saturday, December 14, 2013 10:31 PM
    Answerer

All replies

  • Probably because File.GetFiles returns and array of files, so the first file would be gottenfile[1], assuming only one file here.

    I would also not recommend putting files and directories in C:\Program Files (x86) since this requires elevated permissions and may not work, or if you make any kind of mistake you could seriously damage your PC by altering files here.

    Saturday, December 14, 2013 7:21 PM
    Moderator
  • A post from another 3.1 exercise user. Chock-full of tips:  :D

    small-basic-technet-tutorial-lesson-31


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Saturday, December 14, 2013 10:31 PM
    Answerer